]> source.dussan.org Git - aspectj.git/commitdiff
242797: latest fixes for using * rather than ? in sigs
authoraclement <aclement>
Fri, 19 Sep 2008 00:14:46 +0000 (00:14 +0000)
committeraclement <aclement>
Fri, 19 Sep 2008 00:14:46 +0000 (00:14 +0000)
weaver/src/org/aspectj/weaver/UnresolvedType.java
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
weaver/testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java

index d1704380b1198e589e85321b87954a1b7bdf6f33..0a9df7d92c6c7f70860348f641b61f881c98e5b8 100644 (file)
@@ -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);
index ea1253a0a4eec310a4e755b6717914bdc82b9733..3e3977b675b8ebec3bbdcb3331419bd5ec6b5729 100644 (file)
@@ -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;
                }
index 0ab904913da774d74e08db72c2b01ef75d0f1e95..73e36177d43d608a9e3005aef315518870ccef21 100644 (file)
@@ -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;
index 2e8de7c7314fe75506ff52196d9dd999df9321ac..0ac1ca7042252964f0bdf56aeadeeb9496c8d2ed 100644 (file)
@@ -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 =