From 6909e5567dc57f68a931490bb6ecfc4adfe8a7f0 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 12 Aug 2011 17:53:46 +0000 Subject: [PATCH] 239649 and primitives no longer all resolved by default --- .../org/aspectj/weaver/CommonWorldTests.java | 36 ++++----- .../org/aspectj/weaver/TestShadow.java | 78 +++++++++++-------- .../reflect/ReflectionWorldSpecificTest.java | 5 +- 3 files changed, 68 insertions(+), 51 deletions(-) diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/CommonWorldTests.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/CommonWorldTests.java index e4dcc8873..faa42b9ed 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/CommonWorldTests.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/CommonWorldTests.java @@ -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 lowerTys = new ArrayList(Arrays.asList(lowerTyArray)); lowerTys.add(ty); - Set allLowerTys = new HashSet(lowerTys); - Set allUpperTys = new HashSet(Arrays.asList(primitives)); + Set allLowerTys = new HashSet(lowerTys); + Set allUpperTys = new HashSet(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 diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/TestShadow.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/TestShadow.java index 761281a48..0a5249245 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/TestShadow.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/TestShadow.java @@ -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"); } diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/reflect/ReflectionWorldSpecificTest.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/reflect/ReflectionWorldSpecificTest.java index 9a841728b..1d3083602 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/reflect/ReflectionWorldSpecificTest.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/reflect/ReflectionWorldSpecificTest.java @@ -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)); } } -- 2.39.5