]> source.dussan.org Git - aspectj.git/commitdiff
239649 and primitives no longer all resolved by default
authoraclement <aclement>
Fri, 12 Aug 2011 17:53:46 +0000 (17:53 +0000)
committeraclement <aclement>
Fri, 12 Aug 2011 17:53:46 +0000 (17:53 +0000)
org.aspectj.matcher/testsrc/org/aspectj/weaver/CommonWorldTests.java
org.aspectj.matcher/testsrc/org/aspectj/weaver/TestShadow.java
org.aspectj.matcher/testsrc/org/aspectj/weaver/reflect/ReflectionWorldSpecificTest.java

index e4dcc8873943749b7a2c6693053df79dffe7fbd4..faa42b9ed4bc5f4b18dd64b055e4df9be5119c1c 100644 (file)
@@ -17,7 +17,6 @@ import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -65,8 +64,8 @@ public abstract class CommonWorldTests extends TestCase {
                                ResolvedType ty1 = primitives[j];
                                if (ty.equals(ty1)) {
                                        isCoerceableFromTest(ty, ty1, true);
-                               } else if (ty == ResolvedType.BOOLEAN || ty1 == ResolvedType.BOOLEAN || ty == ResolvedType.VOID
-                                               || ty1 == ResolvedType.VOID) {
+                               } else if (ty.equals(UnresolvedType.BOOLEAN) || ty1.equals(UnresolvedType.BOOLEAN)
+                                               || ty.equals(UnresolvedType.VOID) || ty1.equals(UnresolvedType.VOID)) {
                                        isCoerceableFromTest(ty, ty1, false);
                                } else {
                                        isCoerceableFromTest(ty, ty1, true);
@@ -90,23 +89,21 @@ public abstract class CommonWorldTests extends TestCase {
        }
 
        private void primAssignTest(String sig, String[] lowers) {
-               ResolvedType[] primitives = getWorld().resolve(primitiveTypes);
+               ResolvedType[] primitives = world.resolve(primitiveTypes);
                UnresolvedType tx = UnresolvedType.forSignature(sig);
-               ResolvedType ty = getWorld().resolve(tx, true);
+               ResolvedType ty = world.resolve(tx, true);
                assertTrue("Couldnt find type " + tx, !ty.isMissing());
-               ResolvedType[] lowerTyArray = getWorld().resolve(UnresolvedType.forSignatures(lowers));
-               List lowerTys = new ArrayList(Arrays.asList(lowerTyArray));
+               ResolvedType[] lowerTyArray = world.resolve(UnresolvedType.forSignatures(lowers));
+               List<ResolvedType> lowerTys = new ArrayList<ResolvedType>(Arrays.asList(lowerTyArray));
                lowerTys.add(ty);
-               Set allLowerTys = new HashSet(lowerTys);
-               Set allUpperTys = new HashSet(Arrays.asList(primitives));
+               Set<ResolvedType> allLowerTys = new HashSet<ResolvedType>(lowerTys);
+               Set<ResolvedType> allUpperTys = new HashSet<ResolvedType>(Arrays.asList(primitives));
                allUpperTys.removeAll(allLowerTys);
 
-               for (Iterator i = allLowerTys.iterator(); i.hasNext();) {
-                       ResolvedType other = (ResolvedType) i.next();
+               for (ResolvedType other : allLowerTys) {
                        isAssignableFromTest(ty, other, true);
                }
-               for (Iterator i = allUpperTys.iterator(); i.hasNext();) {
-                       ResolvedType other = (ResolvedType) i.next();
+               for (ResolvedType other : allUpperTys) {
                        isAssignableFromTest(ty, other, false);
                }
        }
@@ -116,7 +113,7 @@ public abstract class CommonWorldTests extends TestCase {
                for (int i = 0, len = primitives.length; i < len; i++) {
                        ResolvedType ty = primitives[i];
                        UnresolvedType tx = UnresolvedType.forSignature("[" + ty.getSignature());
-                       ResolvedType aty = getWorld().resolve(tx, true);
+                       ResolvedType aty = world.resolve(tx, true);
                        assertTrue("Couldnt find type " + tx, !aty.isMissing());
                        modifiersTest(aty, Modifier.PUBLIC | Modifier.FINAL);
                        fieldsTest(aty, ResolvedMember.NONE);
@@ -150,7 +147,7 @@ public abstract class CommonWorldTests extends TestCase {
                for (int i = 0, len = primitives.length; i < len; i++) {
                        ResolvedType ty = primitives[i];
                        UnresolvedType tx = UnresolvedType.forSignature("[[" + ty.getSignature());
-                       ResolvedType aty = getWorld().resolve(tx, true);
+                       ResolvedType aty = world.resolve(tx, true);
                        assertTrue("Couldnt find type " + tx, !aty.isMissing());
                        modifiersTest(aty, Modifier.PUBLIC | Modifier.FINAL);
                        fieldsTest(aty, ResolvedMember.NONE);
@@ -243,12 +240,15 @@ public abstract class CommonWorldTests extends TestCase {
        }
 
        protected void isCoerceableFromTest(UnresolvedType ty0, UnresolvedType ty1, boolean x) {
-               assertEquals(ty0 + " is coerceable from " + ty1, x, ty0.resolve(world).isCoerceableFrom(ty1.resolve(world)));
-               assertEquals(ty1 + " is coerceable from " + ty0, x, ty1.resolve(world).isCoerceableFrom(ty0.resolve(world)));
+               assertEquals(ty0 + " is coerceable from " + ty1, ty0.resolve(world).isCoerceableFrom(ty1.resolve(world)), x);
+               assertEquals(ty1 + " is coerceable from " + ty0, ty1.resolve(world).isCoerceableFrom(ty0.resolve(world)), x);
        }
 
        protected void isAssignableFromTest(UnresolvedType ty0, UnresolvedType ty1, boolean x) {
-               assertEquals(ty0 + " is assignable from " + ty1, x, ty0.resolve(world).isAssignableFrom(ty1.resolve(world)));
+               ResolvedType rty0 = ty0.resolve(world);
+               ResolvedType rty1 = ty1.resolve(world);
+               boolean result = rty0.isAssignableFrom(rty1);
+               assertEquals(ty0 + " is assignable from " + ty1, result, x);
        }
 
        // ---- tests for parts of ResolvedMethod objects
index 761281a486ec7614820436b6ece6363307cb5fcb..0a5249245bf0b62aa284e60751434c5292e99523 100644 (file)
@@ -10,7 +10,6 @@
  *     PARC     initial implementation 
  * ******************************************************************/
 
-
 package org.aspectj.weaver;
 
 import org.aspectj.bridge.ISourceLocation;
@@ -21,39 +20,44 @@ public class TestShadow extends Shadow {
        private final World world;
        private final UnresolvedType thisType;
 
-    public TestShadow(Kind kind, Member signature, UnresolvedType thisType, World world) {
-        super(kind, signature, null);
-        this.world = world;
-        this.thisType = thisType;
-    }
+       public TestShadow(Kind kind, Member signature, UnresolvedType thisType, World world) {
+               super(kind, signature, null);
+               this.world = world;
+               this.thisType = thisType;
+       }
 
-    public World getIWorld() {
-        return world;
-    }
+       public World getIWorld() {
+               return world;
+       }
 
-       /** this is subtly wrong.  ha ha */
-    public UnresolvedType getEnclosingType() {
-        return thisType;
-    }
+       /** this is subtly wrong. ha ha */
+       public UnresolvedType getEnclosingType() {
+               return thisType;
+       }
 
-    public Var getThisVar() {
-       // we should thorw if we don't have a this
-        return new Var(getThisType().resolve(world));
-    }
+       public Var getThisVar() {
+               // we should thorw if we don't have a this
+               return new Var(getThisType().resolve(world));
+       }
 
-    public Var getTargetVar() {
-       if (! hasTarget()) throw new RuntimeException("bad");
-        return new Var(getTargetType().resolve(world));
-    }
+       public Var getTargetVar() {
+               if (!hasTarget())
+                       throw new RuntimeException("bad");
+               return new Var(getTargetType().resolve(world));
+       }
 
-    public Var getArgVar(int i) {
-        return new Var(getArgType(i).resolve(world));
-    }
+       public Var getArgVar(int i) {
+               return new Var(getArgType(i).resolve(world));
+       }
 
        public Var getThisEnclosingJoinPointStaticPartVar() {
                throw new RuntimeException("unimplemented");
        }
 
+       public Var getThisAspectInstanceVar(ResolvedType aspectType) {
+               throw new RuntimeException("unimplemented");
+       }
+
        public Var getThisJoinPointStaticPartVar() {
                throw new RuntimeException("unimplemented");
        }
@@ -70,45 +74,57 @@ public class TestShadow extends Shadow {
                throw new RuntimeException("unimplemented");
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.aspectj.weaver.Shadow#getKindedAnnotationVar()
         */
        public Var getKindedAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.aspectj.weaver.Shadow#getWithinAnnotationVar()
         */
        public Var getWithinAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.aspectj.weaver.Shadow#getWithinCodeAnnotationVar()
         */
        public Var getWithinCodeAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.aspectj.weaver.Shadow#getThisAnnotationVar()
         */
        public Var getThisAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.aspectj.weaver.Shadow#getTargetAnnotationVar()
         */
        public Var getTargetAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.aspectj.weaver.Shadow#getArgAnnotationVar(int)
         */
-       public Var getArgAnnotationVar(int i,UnresolvedType annotationType) {
+       public Var getArgAnnotationVar(int i, UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
 
index 9a841728b9eae0548e93ba1e47f4fde9378010a8..1d3083602a0ec82ff3c1655be737dbc183d5255a 100644 (file)
@@ -14,6 +14,7 @@ package org.aspectj.weaver.reflect;
 import junit.framework.TestCase;
 
 import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.World;
 
 public class ReflectionWorldSpecificTest extends TestCase {
@@ -34,8 +35,8 @@ public class ReflectionWorldSpecificTest extends TestCase {
 
        public void testPrimitiveTypes() {
                IReflectionWorld world = new ReflectionWorld(true, getClass().getClassLoader());
-               assertEquals("int", ResolvedType.INT, world.resolve(int.class));
-               assertEquals("void", ResolvedType.VOID, world.resolve(void.class));
+               assertEquals("int", UnresolvedType.INT, world.resolve(int.class));
+               assertEquals("void", UnresolvedType.VOID, world.resolve(void.class));
        }
 
 }