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);
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;
// 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;
}
*
*/
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;
}
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;
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());
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);
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 =