return TypeX.forName(getName(tvb.superclass));
}
}
- // FIXME asc/amc cope properly with RawTypeBindings
- if (binding instanceof ParameterizedTypeBinding && !(binding instanceof RawTypeBinding)) {
+
+ if (binding instanceof ParameterizedTypeBinding) {
+ if (binding instanceof RawTypeBinding) {
+ // special case where no parameters are specified!
+ return TypeX.forRawTypeNames(getName(binding));
+ }
ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) binding;
String[] arguments = new String[ptb.arguments.length];
for (int i = 0; i < arguments.length; i++) {
typeX = typeX.getComponentType();
}
return lookupEnvironment.createArrayType(makeTypeBinding(typeX), dim);
- } else if (typeX.isParameterized()){
- TypeX[] typeParameters = typeX.getTypeParameters();
- ReferenceBinding baseTypeBinding = lookupBinding(typeX.getBaseName());
- ReferenceBinding[] argumentBindings = new ReferenceBinding[typeParameters.length];
- for (int i = 0; i < argumentBindings.length; i++) {
- argumentBindings[i] = lookupBinding(typeParameters[i].getName());
+ } else if (typeX.isParameterized()) {
+ if (typeX.isRawType()) {
+ ReferenceBinding baseTypeBinding = lookupBinding(typeX.getBaseName());
+ RawTypeBinding rtb = lookupEnvironment.createRawType(baseTypeBinding,baseTypeBinding.enclosingType());
+ return rtb;
+ } else {
+ TypeX[] typeParameters = typeX.getTypeParameters();
+ ReferenceBinding baseTypeBinding = lookupBinding(typeX.getBaseName());
+ ReferenceBinding[] argumentBindings = new ReferenceBinding[typeParameters.length];
+ for (int i = 0; i < argumentBindings.length; i++) {
+ argumentBindings[i] = lookupBinding(typeParameters[i].getName());
+ }
+ ParameterizedTypeBinding ptb =
+ lookupEnvironment.createParameterizedType(baseTypeBinding,argumentBindings,baseTypeBinding.enclosingType());
+ return ptb;
}
- ParameterizedTypeBinding ptb =
- lookupEnvironment.createParameterizedType(baseTypeBinding,argumentBindings,baseTypeBinding.enclosingType());
- return ptb;
} else {
return lookupBinding(typeX.getName());
}
--- /dev/null
+import java.util.*;
+
+aspect X {
+
+ private Set PR91053.aSet = new HashSet();
+
+ public void PR91053.add(String s) {
+ aSet.add(s);
+ }
+
+}
+
+public class PR91053 {
+
+ public static void main(String[]argv) {
+ new PR91053().add("hello");
+ }
+}
public void testPR91267_2() {
runTest("NPE using generic methods in aspects 2");
}
+
+ public void testPR91053() {
+ runTest("Generics problem with Set");
+ }
}
<compile files="TestBug2.aj" options="-1.5"/>
<run class="TestBug2"/>
</ajc-test>
+
+ <ajc-test dir="java5/generics/bugs" title="Generics problem with Set" vm="1.5">
+ <compile files="PR91053.aj" options="-1.5"/>
+ <run class="PR91053"/>
+ </ajc-test>
</suite>
\ No newline at end of file
* If this is a parameterized type, these are its parameters
*/
protected TypeX[] typeParameters;
+
+ protected boolean isParameterized = false;
/**
* @param signature the bytecode string representation of this Type
*/
public static TypeX forParameterizedTypeNames(String name, String[] paramTypeNames) {
TypeX ret = TypeX.forName(name);
+ ret.setParameterized(true);
ret.typeParameters = new TypeX[paramTypeNames.length];
for (int i = 0; i < paramTypeNames.length; i++) {
ret.typeParameters[i] = TypeX.forName(paramTypeNames[i]);
return ret;
}
+ public static TypeX forRawTypeNames(String name) {
+ TypeX ret = TypeX.forName(name);
+ ret.setParameterized(true);
+ // FIXME asc no need to mess up the signature is there?
+ // ret.signature = ret.signature+"#RAW";
+ return ret;
+ }
+
/**
* Creates a new type array with a fresh type appended to the end.
*
public String getBaseName() {
String name = getName();
if (isParameterized()) {
- return name.substring(0,name.indexOf("<"));
+ if (isRawType()) return name;
+ else return name.substring(0,name.indexOf("<"));
} else {
return name;
}
* Determines if this represents a parameterized type.
*/
public final boolean isParameterized() {
- return signature.indexOf("<") != -1;
- //(typeParameters != null) && (typeParameters.length > 0);
+ return isParameterized;
+// return signature.indexOf("<") != -1;
+// //(typeParameters != null) && (typeParameters.length > 0);
}
+
+ public final boolean isRawType() {
+ return isParameterized && typeParameters==null;
+ }
+
+ private final void setParameterized(boolean b) { isParameterized=b;}
+
/**
* Returns a TypeX object representing the effective outermost enclosing type
dumpState_cantFindTypeExceptions.add(new RuntimeException("Can't find type "+ty.getName()));
}
}
- if (ty.isParameterized()) {
+ if (ty.isParameterized() && !ty.isRawType()) {
for (int i = 0; i < ty.typeParameters.length; i++) {
ty.typeParameters[i] = resolve(ty.typeParameters[i],allowMissing);
}