From b0450ebd70d0a415da1d6e9a6c35c82a9b038c91 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 19 Sep 2008 00:14:46 +0000 Subject: [PATCH] 242797: latest fixes for using * rather than ? in sigs --- weaver/src/org/aspectj/weaver/UnresolvedType.java | 2 +- weaver/src/org/aspectj/weaver/World.java | 7 ++++--- .../org/aspectj/weaver/patterns/WildTypePattern.java | 5 +++-- .../patterns/WildTypePatternResolutionTestCase.java | 10 ++++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/UnresolvedType.java b/weaver/src/org/aspectj/weaver/UnresolvedType.java index d1704380b..0a9df7d92 100644 --- a/weaver/src/org/aspectj/weaver/UnresolvedType.java +++ b/weaver/src/org/aspectj/weaver/UnresolvedType.java @@ -695,7 +695,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { return "? extends " + signatureToName(signature.substring(1, signature.length())); case '-': return "? super " + signatureToName(signature.substring(1, signature.length())); - case '?': + case '*': return "?"; default: throw new BCException("Bad type signature: " + signature); diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index ea1253a0a..3e3977b67 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -67,10 +67,10 @@ public abstract class World implements Dump.INode { public static boolean createInjarHierarchy = true; /** Calculator for working out aspect precedence */ - private AspectPrecedenceCalculator precedenceCalculator; + private final AspectPrecedenceCalculator precedenceCalculator; /** All of the type and shadow mungers known to us */ - private CrosscuttingMembersSet crosscuttingMembersSet = new CrosscuttingMembersSet(this); + private final CrosscuttingMembersSet crosscuttingMembersSet = new CrosscuttingMembersSet(this); /** Model holds ASM relationships */ private IHierarchy model = null; @@ -243,7 +243,8 @@ public abstract class World implements Dump.INode { // might be a problem here, not sure '?' should make it to here as a signature, the // proper signature for wildcard '?' is '*' // fault in generic wildcard, can't be done earlier because of init issues - ResolvedType something = new BoundedReferenceType("?", "Ljava/lang/Object", this); + // TODO ought to be shared single instance representing this + ResolvedType something = new BoundedReferenceType("*", "Ljava/lang/Object", this); typeMap.put("?", something); return something; } diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index 0ab904913..73e36177d 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -85,7 +85,8 @@ import org.aspectj.weaver.World; * */ public class WildTypePattern extends TypePattern { - private static final String GENERIC_WILDCARD_CHARACTER = "?"; + private static final String GENERIC_WILDCARD_CHARACTER = "?"; // signature of ? is * + private static final String GENERIC_WILDCARD_SIGNATURE_CHARACTER = "*"; // signature of ? is * private NamePattern[] namePatterns; int ellipsisCount; String[] importedPrefixes; @@ -774,7 +775,7 @@ public class WildTypePattern extends TypePattern { } private TypePattern resolveGenericWildcard(IScope scope, UnresolvedType aType) { - if (!aType.getSignature().equals(GENERIC_WILDCARD_CHARACTER)) throw new IllegalStateException("Can only have bounds for a generic wildcard"); + if (!aType.getSignature().equals(GENERIC_WILDCARD_SIGNATURE_CHARACTER)) throw new IllegalStateException("Can only have bounds for a generic wildcard"); boolean canBeExact = true; if ((upperBound != null) && ResolvedType.isMissing(upperBound.getExactType())) canBeExact = false; if ((lowerBound != null) && ResolvedType.isMissing(lowerBound.getExactType())) canBeExact = false; diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java index 2e8de7c73..0ac1ca704 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java @@ -169,12 +169,12 @@ import org.aspectj.weaver.bcel.BcelWorld; assertTrue("resolves to exact type",rtp instanceof ExactTypePattern); UnresolvedType exactType = rtp.getExactType(); assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List;",exactType.getSignature()); + assertEquals("Pjava/util/List<*>;",exactType.getSignature()); ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp); exactType = etp.getExactType(); assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List;",exactType.getSignature()); + assertEquals("Pjava/util/List<*>;",exactType.getSignature()); assertFalse("does not match List",etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); assertFalse("does not match generic List",etp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue()); @@ -345,7 +345,8 @@ import org.aspectj.weaver.bcel.BcelWorld; new UnresolvedType[] {UnresolvedType.forName("java.lang.Double").resolve(world)}, world); - assertFalse("does not match list of number",wtp.matches(listOfNumber,TypePattern.STATIC).alwaysTrue()); + boolean matchesListOfNumber = wtp.matches(listOfNumber,TypePattern.STATIC).alwaysTrue(); + assertFalse("does not match list of number",matchesListOfNumber); assertFalse("does not match list of double",wtp.matches(listOfDouble,TypePattern.STATIC).alwaysTrue()); ResolvedType extendsNumber = TypeFactory.createTypeFromSignature("+Ljava/lang/Number;").resolve(world); @@ -355,7 +356,8 @@ import org.aspectj.weaver.bcel.BcelWorld; new UnresolvedType[] {extendsNumber}, world); - assertTrue("matches list of ? extends number",wtp.matches(listOfExtendsNumber,TypePattern.STATIC).alwaysTrue()); + boolean matchesListOfQmarkExtendsNumber = wtp.matches(listOfExtendsNumber,TypePattern.STATIC).alwaysTrue(); + assertTrue("failed to correctly match list of ? extends number",matchesListOfQmarkExtendsNumber); ResolvedType extendsDouble = TypeFactory.createTypeFromSignature("+Ljava/lang/Double;").resolve(world); ResolvedType listOfExtendsDouble = -- 2.39.5