--- /dev/null
+import java.util.*;
+
+public class TTT {
+ public void foo() {
+ System.err.println("Creating Test<Integer> instance");
+ Test<Integer> mt = new Test<Integer>();
+ System.err.println("Calling toArray");
+ Integer[] arr = mt.toArray(new Integer[]{});
+ System.err.println("done");
+ }
+}
--- /dev/null
+import java.util.*;
+
+public class Test<T> {
+
+ Set<T> set = new HashSet<T>();
+
+ public <T> T[] toArray(T[] a) {
+ System.err.println("In toArray()");
+ return set.toArray(a);
+ }
+}
--- /dev/null
+import java.util.*;
+
+public privileged aspect TestAspect {
+
+ pointcut TestToArray(Test mt) :
+ target(mt) &&
+ !within(TestAspect);
+
+
+ Object[] around(Test mt, Object[] objs) :
+ TestToArray(mt) &&
+ args(objs) &&
+ execution(Object[] Test.toArray(Object[])) {
+
+ System.err.println("In around advice");
+ objs = proceed(mt, objs);
+ return objs;
+ }
+
+ public static void main(String[] argv) {
+ System.err.println("TestAspect.main: Calling foo");
+ new TTT().foo();
+ System.err.println("TestAspect.main: done");
+ }
+}
public void testMatthewsAspect_pr113947_1() { runTest("maws generic aspect - 1");}
public void testMatthewsAspect_pr113947_2() { runTest("maws generic aspect - 2");}
public void testFieldGet_pr114343() { runTest("field-get, generics and around advice");}
+ public void testFieldGet_pr114343_2() { runTest("field-get, generics and around advice - 2");}
public void testCaptureBinding_pr114744() { runTest("capturebinding wildcard problem");}
public void testBadDecp_pr110788_1() { runTest("bad generic decp - 1");}
<run class="TestAspect"/>
</ajc-test>
+ <ajc-test dir="bugs150/pr114343/case2" title="field-get, generics and around advice - 2">
+ <compile files="Test.java,TTT.java,TestAspect.java" options="-1.5"/>
+ <run class="TestAspect">
+ <stderr>
+ <line text="TestAspect.main: Calling foo"/>
+ <line text="Creating Test<Integer> instance"/>
+ <line text="Calling toArray"/>
+ <line text="In around advice"/>
+ <line text="In toArray()"/>
+ <line text="done"/>
+ <line text="TestAspect.main: done"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
<ajc-test dir="bugs150/pr113947/case1" title="maws generic aspect - 1">
<compile files="AbstractListSupport.java,AnotherItem.java,Item.java,LinkedList.java,LinkedListItem.java,ListItem.java,StringList.java" options="-1.5">
<!-- the 'static ref' messages are a bit poor and ought to be eliminated... -->
}
}
+ if (isTypeVariableReference() && !other.isTypeVariableReference()) { // eg. this=T other=Ljava/lang/Object;
+ TypeVariable aVar = ((TypeVariableReference)this).getTypeVariable();
+ return aVar.getFirstBound().resolve(world).isAssignableFrom(other);
+ }
+
if (other.isTypeVariableReference()) {
TypeVariableReferenceType otherType = (TypeVariableReferenceType) other;
if (this instanceof TypeVariableReference) {
// ---- types
public static ResolvedType makeArray(ResolvedType type, int dim) {
if (dim == 0) return type;
- ResolvedType array = new Array("[" + type.getSignature(),type.getWorld(),type);
+ ResolvedType array = new Array("[" + type.getSignature(),"["+type.getErasureSignature(),type.getWorld(),type);
return makeArray(array,dim-1);
}
static class Array extends ResolvedType {
ResolvedType componentType;
- Array(String s, World world, ResolvedType componentType) {
- super(s, world);
+
+
+ // Sometimes the erasure is different, eg. [TT; and [Ljava/lang/Object;
+ Array(String sig, String erasureSig,World world, ResolvedType componentType) {
+ super(sig,erasureSig, world);
this.componentType = componentType;
}
public final ResolvedMember[] getDeclaredFields() {
typeVariableName = typeVariableName.substring(0, typeVariableName.length() -1);
}
return new UnresolvedTypeVariableReferenceType(new TypeVariable(typeVariableName));
+ } else if (signature.startsWith("[")) {
+ int dims = 0;
+ while (signature.charAt(dims)=='[') dims++;
+ UnresolvedType componentType = createTypeFromSignature(signature.substring(dims));
+ return new UnresolvedType(signature,
+ signature.substring(0,dims)+componentType.getErasureSignature());
}
return new UnresolvedType(signature);
}
// no existing resolved type, create one
if (ty.isArray()) {
- ret = new ResolvedType.Array(signature,
+ ResolvedType componentType = resolve(ty.getComponentType(),allowMissing);
+ String brackets = signature.substring(0,signature.lastIndexOf("[")+1);
+ ret = new ResolvedType.Array(signature, brackets+componentType.getErasureSignature(),
this,
- resolve(ty.getComponentType(),
- allowMissing));
+ componentType);
} else {
ret = resolveToReferenceType(ty);
if (!allowMissing && ret == ResolvedType.MISSING) {
return resolve(UnresolvedType.forName(name),allowMissing);
}
-
+ private ResolvedType currentlyResolvingBaseType;
+
/**
* Resolve to a ReferenceType - simple, raw, parameterized, or generic.
* Raw, parameterized, and generic versions of a type share a delegate.
if (ty.isParameterizedType()) {
// ======= parameterized types ================
ReferenceType genericType = (ReferenceType)resolveGenericTypeFor(ty,false);
+ currentlyResolvingBaseType = genericType;
ReferenceType parameterizedType =
TypeFactory.createParameterizedType(genericType, ty.typeParameters, this);
+ currentlyResolvingBaseType = null;
return parameterizedType;
} else if (ty.isGenericType()) {