@@ -192,8 +192,12 @@ public class EclipseFactory { | |||
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++) { | |||
@@ -348,16 +352,22 @@ public class EclipseFactory { | |||
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()); | |||
} |
@@ -0,0 +1,18 @@ | |||
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"); | |||
} | |||
} |
@@ -27,4 +27,8 @@ public class GenericsTests extends XMLBasedAjcTestCase { | |||
public void testPR91267_2() { | |||
runTest("NPE using generic methods in aspects 2"); | |||
} | |||
public void testPR91053() { | |||
runTest("Generics problem with Set"); | |||
} | |||
} |
@@ -2164,5 +2164,10 @@ | |||
<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> |
@@ -28,6 +28,8 @@ public class TypeX implements AnnotatedElement { | |||
* 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 | |||
@@ -114,6 +116,7 @@ public class TypeX implements AnnotatedElement { | |||
*/ | |||
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]); | |||
@@ -130,6 +133,14 @@ public class TypeX implements AnnotatedElement { | |||
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. | |||
* | |||
@@ -237,7 +248,8 @@ public class TypeX implements AnnotatedElement { | |||
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; | |||
} | |||
@@ -292,9 +304,17 @@ public class TypeX implements AnnotatedElement { | |||
* 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 |
@@ -137,7 +137,7 @@ public abstract class World implements Dump.INode { | |||
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); | |||
} |