diff options
author | Andy Clement <andrew.clement@gmail.com> | 2012-06-15 17:42:25 -0700 |
---|---|---|
committer | Andy Clement <andrew.clement@gmail.com> | 2012-06-15 17:42:25 -0700 |
commit | a7483038e86dd39894d9b347f227eb6c3a33e09e (patch) | |
tree | 4a0b8bdfa50bb7d26814f0aff6d6f1ebca32b1de | |
parent | ba9d43ccaf2660ddc9916ea48f79a77ba60d435e (diff) | |
download | aspectj-a7483038e86dd39894d9b347f227eb6c3a33e09e.tar.gz aspectj-a7483038e86dd39894d9b347f227eb6c3a33e09e.zip |
382189 and 382435
40 files changed, 249 insertions, 32 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index 0659dfc1e..a87a69871 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -2402,19 +2402,18 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } /** - * Iff I am a parameterized type, and any of my parameters are type variable references, return a version with those type - * parameters replaced in accordance with the passed bindings. + * Iff I am a parameterized type, and any of my parameters are type variable references (or nested parameterized types), + * return a version with those type parameters replaced in accordance with the passed bindings. */ @Override public UnresolvedType parameterize(Map<String, UnresolvedType> typeBindings) { if (!isParameterizedType()) { - return this;// throw new IllegalStateException( + // throw new IllegalStateException("Can't parameterize a type that is not a parameterized type"); + return this; } - // "Can't parameterize a type that is not a parameterized type" - // ); boolean workToDo = false; for (int i = 0; i < typeParameters.length; i++) { - if (typeParameters[i].isTypeVariableReference() || (typeParameters[i] instanceof BoundedReferenceType)) { + if (typeParameters[i].isTypeVariableReference() || (typeParameters[i] instanceof BoundedReferenceType) || typeParameters[i].isParameterizedType()) { workToDo = true; } } @@ -2434,6 +2433,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl BoundedReferenceType brType = (BoundedReferenceType) newTypeParams[i]; newTypeParams[i] = brType.parameterize(typeBindings); // brType.parameterize(typeBindings) + } else if (newTypeParams[i].isParameterizedType()) { + newTypeParams[i] = newTypeParams[i].parameterize(typeBindings); } } return TypeFactory.createParameterizedType(getGenericType(), newTypeParams, getWorld()); diff --git a/tests/bugs170/pr382189/covbug/A.java b/tests/bugs170/pr382189/covbug/A.java new file mode 100644 index 000000000..1bf20c5b6 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/A.java @@ -0,0 +1,2 @@ +package covbug;
+public class A { }
diff --git a/tests/bugs170/pr382189/covbug/A_ITD.aj b/tests/bugs170/pr382189/covbug/A_ITD.aj new file mode 100644 index 000000000..5cf1a73fa --- /dev/null +++ b/tests/bugs170/pr382189/covbug/A_ITD.aj @@ -0,0 +1,12 @@ +package covbug;
+
+
+public privileged aspect A_ITD {
+ declare parents: A extends SuperA<String>;
+
+
+ public B A.getSomeB(SuperB<String> b){
+ return null;
+ }
+
+}
diff --git a/tests/bugs170/pr382189/covbug/B.java b/tests/bugs170/pr382189/covbug/B.java new file mode 100644 index 000000000..1184552ef --- /dev/null +++ b/tests/bugs170/pr382189/covbug/B.java @@ -0,0 +1,3 @@ +package covbug;
+ +public class B extends SuperB<String> { }
diff --git a/tests/bugs170/pr382189/covbug/SuperA.java b/tests/bugs170/pr382189/covbug/SuperA.java new file mode 100644 index 000000000..288b9f9a3 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/SuperA.java @@ -0,0 +1,6 @@ +package covbug;
+import java.util.List;
+
+public abstract class SuperA<T> {
+ public abstract SuperB<T> getSomeB(SuperB<T> b);
+}
diff --git a/tests/bugs170/pr382189/covbug/SuperB.java b/tests/bugs170/pr382189/covbug/SuperB.java new file mode 100644 index 000000000..8a6c2c2dd --- /dev/null +++ b/tests/bugs170/pr382189/covbug/SuperB.java @@ -0,0 +1,3 @@ +package covbug;
+
+public class SuperB<T> { }
diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/A.class b/tests/bugs170/pr382189/covbug/cc/covbug/A.class Binary files differnew file mode 100644 index 000000000..59a59b710 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/A.class diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/A.java b/tests/bugs170/pr382189/covbug/cc/covbug/A.java new file mode 100644 index 000000000..1c0499f94 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/A.java @@ -0,0 +1,10 @@ +package covbug; + + +public class A extends SuperA<String> { + public B getSomeB(SuperB<String> b){ + return null; + } + + +} diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/A_ITD.aj b/tests/bugs170/pr382189/covbug/cc/covbug/A_ITD.aj new file mode 100644 index 000000000..5cf1a73fa --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/A_ITD.aj @@ -0,0 +1,12 @@ +package covbug;
+
+
+public privileged aspect A_ITD {
+ declare parents: A extends SuperA<String>;
+
+
+ public B A.getSomeB(SuperB<String> b){
+ return null;
+ }
+
+}
diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/B.class b/tests/bugs170/pr382189/covbug/cc/covbug/B.class Binary files differnew file mode 100644 index 000000000..91debf8f1 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/B.class diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/B.java b/tests/bugs170/pr382189/covbug/cc/covbug/B.java new file mode 100644 index 000000000..cdfd1f70b --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/B.java @@ -0,0 +1,8 @@ +package covbug; + + +public class B extends SuperB<String> { + + + +} diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.class b/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.class Binary files differnew file mode 100644 index 000000000..d5ba823f3 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.class diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.java b/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.java new file mode 100644 index 000000000..dfb721b71 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.java @@ -0,0 +1,7 @@ +package covbug; + +import java.util.List; + +public abstract class SuperA<T> { + public abstract SuperB<T> getSomeB(SuperB<T> b); +} diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.class b/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.class Binary files differnew file mode 100644 index 000000000..cd3b522ad --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.class diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.java b/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.java new file mode 100644 index 000000000..2f5167d3e --- /dev/null +++ b/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.java @@ -0,0 +1,5 @@ +package covbug; + +public class SuperB<T> { + +} diff --git a/tests/bugs170/pr382189/covbug/pj/A.class b/tests/bugs170/pr382189/covbug/pj/A.class Binary files differnew file mode 100644 index 000000000..4f315b411 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/pj/A.class diff --git a/tests/bugs170/pr382189/covbug/pj/B.class b/tests/bugs170/pr382189/covbug/pj/B.class Binary files differnew file mode 100644 index 000000000..11e52e8db --- /dev/null +++ b/tests/bugs170/pr382189/covbug/pj/B.class diff --git a/tests/bugs170/pr382189/covbug/pj/Foo.java b/tests/bugs170/pr382189/covbug/pj/Foo.java new file mode 100644 index 000000000..d8e1721b2 --- /dev/null +++ b/tests/bugs170/pr382189/covbug/pj/Foo.java @@ -0,0 +1,26 @@ +import java.util.List; + +class A extends SuperA<String> { + public B getSomeB(SuperB<String> b) { return null; } + public static void main(String []argv) { + A a = new A(); + System.out.println(a.getSomeB(null)); + } +} + +class B extends SuperB<String> { +} + +abstract class SuperA<T> { + public abstract SuperB<T> getSomeB(SuperB<T> b); +} + +class SuperB<T> { } + +/* +public privileged aspect A_ITD { + declare parents: A extends SuperA<String>; + + public B A.getSomeB(SuperB<String> b) { return null; } +} +*/ diff --git a/tests/bugs170/pr382189/covbug/pj/SuperA.class b/tests/bugs170/pr382189/covbug/pj/SuperA.class Binary files differnew file mode 100644 index 000000000..93153a47c --- /dev/null +++ b/tests/bugs170/pr382189/covbug/pj/SuperA.class diff --git a/tests/bugs170/pr382189/covbug/pj/SuperB.class b/tests/bugs170/pr382189/covbug/pj/SuperB.class Binary files differnew file mode 100644 index 000000000..7f4c4e51b --- /dev/null +++ b/tests/bugs170/pr382189/covbug/pj/SuperB.class diff --git a/tests/bugs170/pr382189/one/A.java b/tests/bugs170/pr382189/one/A.java new file mode 100644 index 000000000..edd16a531 --- /dev/null +++ b/tests/bugs170/pr382189/one/A.java @@ -0,0 +1 @@ +public class A extends SuperA<String> { } diff --git a/tests/bugs170/pr382189/one/A_ITD.aj b/tests/bugs170/pr382189/one/A_ITD.aj new file mode 100644 index 000000000..7c5be5c9f --- /dev/null +++ b/tests/bugs170/pr382189/one/A_ITD.aj @@ -0,0 +1,6 @@ + +public privileged aspect A_ITD { + public B A.getSomeB(SuperB<String> b){ + return null; + } +} diff --git a/tests/bugs170/pr382189/one/B.java b/tests/bugs170/pr382189/one/B.java new file mode 100644 index 000000000..b32fa4ef7 --- /dev/null +++ b/tests/bugs170/pr382189/one/B.java @@ -0,0 +1 @@ +public class B extends SuperB<String> { } diff --git a/tests/bugs170/pr382189/one/SuperA.java b/tests/bugs170/pr382189/one/SuperA.java new file mode 100644 index 000000000..09755a197 --- /dev/null +++ b/tests/bugs170/pr382189/one/SuperA.java @@ -0,0 +1,5 @@ +import java.util.List; + +public abstract class SuperA<T> { + public abstract SuperB<T> getSomeB(SuperB<T> b); +} diff --git a/tests/bugs170/pr382189/one/SuperB.java b/tests/bugs170/pr382189/one/SuperB.java new file mode 100644 index 000000000..a5098aa84 --- /dev/null +++ b/tests/bugs170/pr382189/one/SuperB.java @@ -0,0 +1,2 @@ + +public class SuperB<T> { } diff --git a/tests/bugs170/pr382189/three/A.java b/tests/bugs170/pr382189/three/A.java new file mode 100644 index 000000000..c24a6f65d --- /dev/null +++ b/tests/bugs170/pr382189/three/A.java @@ -0,0 +1,6 @@ +public class A { + public static void main(String []argv) { + A a = new A(); + System.out.println(a.getSomeB(null)); + } +} diff --git a/tests/bugs170/pr382189/three/A_ITD.aj b/tests/bugs170/pr382189/three/A_ITD.aj new file mode 100644 index 000000000..39b55978f --- /dev/null +++ b/tests/bugs170/pr382189/three/A_ITD.aj @@ -0,0 +1,7 @@ + +public privileged aspect A_ITD { + declare parents: A extends SuperA<String>; + public B A.getSomeB(SuperB<String> b){ + return null; + } +} diff --git a/tests/bugs170/pr382189/three/B.java b/tests/bugs170/pr382189/three/B.java new file mode 100644 index 000000000..db22693a2 --- /dev/null +++ b/tests/bugs170/pr382189/three/B.java @@ -0,0 +1,2 @@ +public class B extends SuperB<String> { +} diff --git a/tests/bugs170/pr382189/three/SuperA.java b/tests/bugs170/pr382189/three/SuperA.java new file mode 100644 index 000000000..09755a197 --- /dev/null +++ b/tests/bugs170/pr382189/three/SuperA.java @@ -0,0 +1,5 @@ +import java.util.List; + +public abstract class SuperA<T> { + public abstract SuperB<T> getSomeB(SuperB<T> b); +} diff --git a/tests/bugs170/pr382189/three/SuperB.java b/tests/bugs170/pr382189/three/SuperB.java new file mode 100644 index 000000000..a5098aa84 --- /dev/null +++ b/tests/bugs170/pr382189/three/SuperB.java @@ -0,0 +1,2 @@ + +public class SuperB<T> { } diff --git a/tests/bugs170/pr382189/two/A.java b/tests/bugs170/pr382189/two/A.java new file mode 100644 index 000000000..9f4b93d84 --- /dev/null +++ b/tests/bugs170/pr382189/two/A.java @@ -0,0 +1 @@ +public class A {} diff --git a/tests/bugs170/pr382189/two/A_ITD.aj b/tests/bugs170/pr382189/two/A_ITD.aj new file mode 100644 index 000000000..39b55978f --- /dev/null +++ b/tests/bugs170/pr382189/two/A_ITD.aj @@ -0,0 +1,7 @@ + +public privileged aspect A_ITD { + declare parents: A extends SuperA<String>; + public B A.getSomeB(SuperB<String> b){ + return null; + } +} diff --git a/tests/bugs170/pr382189/two/B.java b/tests/bugs170/pr382189/two/B.java new file mode 100644 index 000000000..b32fa4ef7 --- /dev/null +++ b/tests/bugs170/pr382189/two/B.java @@ -0,0 +1 @@ +public class B extends SuperB<String> { } diff --git a/tests/bugs170/pr382189/two/SuperA.java b/tests/bugs170/pr382189/two/SuperA.java new file mode 100644 index 000000000..09755a197 --- /dev/null +++ b/tests/bugs170/pr382189/two/SuperA.java @@ -0,0 +1,5 @@ +import java.util.List; + +public abstract class SuperA<T> { + public abstract SuperB<T> getSomeB(SuperB<T> b); +} diff --git a/tests/bugs170/pr382189/two/SuperB.java b/tests/bugs170/pr382189/two/SuperB.java new file mode 100644 index 000000000..a5098aa84 --- /dev/null +++ b/tests/bugs170/pr382189/two/SuperB.java @@ -0,0 +1,2 @@ + +public class SuperB<T> { } diff --git a/tests/bugs170/pr382435/one/bug/A.java b/tests/bugs170/pr382435/one/bug/A.java new file mode 100644 index 000000000..a331bcc47 --- /dev/null +++ b/tests/bugs170/pr382435/one/bug/A.java @@ -0,0 +1,17 @@ +package bug; + +import java.util.List; + +public class A {}//extends B<String> { } + +abstract class B<T> { + public abstract List<List<T>> getList(); +} + +privileged aspect A_ITD { + declare parents: A extends B<String>; + + public List<List<String>> A.getList(){ + return null; + } +} diff --git a/tests/bugs170/pr382435/two/bug/A.java b/tests/bugs170/pr382435/two/bug/A.java new file mode 100644 index 000000000..f4d08be5c --- /dev/null +++ b/tests/bugs170/pr382435/two/bug/A.java @@ -0,0 +1,21 @@ +package bug; + +import java.util.List; + +public class A { + public static void main(String[] argv) { + new A().getList(); + } +}//extends B<String> { } + +abstract class B<T> { + public abstract List<List<T>> getList(); +} + +privileged aspect A_ITD { + declare parents: A extends B<String>; + + public List<List<String>> A.getList(){ + return null; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java index 3585e782a..c9b1a7377 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java @@ -39,6 +39,30 @@ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // runTest("missing annos on priv aspects - 2"); // } + public void testCovariantGenerics382435_1() { + runTest("covariant generic itds 1"); + } + + public void testCovariantGenerics382435_2() { + runTest("covariant generic itds 2"); + } + + public void testCovariantGenericsItd382189_1() { + runTest("covariant generics 1"); + } + + public void testCovariantGenericsItd382189_2() { + runTest("covariant generics 2"); + } + + public void testCovariantGenericsItd382189_3() { + runTest("covariant generics 3"); + } + + public void testCovariantGenericsItd382189() { + runTest("covariant generics"); + } + public void testGenericAspectAround382723() { runTest("generic aspect"); } @@ -55,9 +79,6 @@ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("generic aspect 4"); } -// public void testCovariantGenericsItd382189() { -// runTest("covariant generics"); -// } public void testAttributeErrorJ7() { runTest("attribute issue with J7"); diff --git a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml index 05ebd0ee2..1413eae39 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml +++ b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml @@ -27,6 +27,32 @@ </run> </ajc-test> + + <!-- no declare parents, only ITD --> + <ajc-test dir="bugs170/pr382189/one" title="covariant generics 1"> + <compile files="A.java A_ITD.aj B.java SuperA.java SuperB.java" options="-1.5"/> + </ajc-test> + + <!-- now declare parents and ITD --> + <ajc-test dir="bugs170/pr382189/two" title="covariant generics 2"> + <compile files="A.java A_ITD.aj B.java SuperA.java SuperB.java" options="-1.5"/> + </ajc-test> + + <!-- now run it --> + <ajc-test dir="bugs170/pr382189/three" title="covariant generics 3"> + <compile files="A.java A_ITD.aj B.java SuperA.java SuperB.java" options="-1.5"/> + <run class="A"/> + </ajc-test> + + <ajc-test dir="bugs170/pr382435/one" title="covariant generic itds 1"> + <compile files="bug/A.java" options="-1.5"/> + </ajc-test> + + <ajc-test dir="bugs170/pr382435/two" title="covariant generic itds 2"> + <compile files="bug/A.java" options="-1.5"/> + <run class="bug.A"/> + </ajc-test> + <ajc-test dir="bugs170/pr382189" title="covariant generics"> <compile files="covbug/A.java covbug/A_ITD.aj covbug/B.java covbug/SuperA.java covbug/SuperB.java" options="-1.5"/> <!-- <run class="Foo"> diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index ac9bacf84..2ae4ac91a 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -1240,7 +1240,9 @@ public class BcelTypeMunger extends ConcreteTypeMunger { boolean quitRightNow = false; String localMethodName = unMangledInterMethod.getName(); - String localParameterSig = unMangledInterMethod.getParameterSignature(); + String erasedSig = unMangledInterMethod.getSignatureErased(); // will be something like (LSuperB;)LFoo; + String localParameterSig = erasedSig.substring(0,erasedSig.lastIndexOf(')')+1);//unMangledInterMethod.getParameterSignature(); + // getParameterSignatureErased() does not include parens, which we do need. String localReturnTypeESig = unMangledInterMethod.getReturnType().getErasureSignature(); // Step1 @@ -1295,28 +1297,10 @@ public class BcelTypeMunger extends ConcreteTypeMunger { InstructionFactory fact; int pos = 0; - LazyMethodGen bridgeMethod = makeMethodGen(clazz, theBridgeMethod); // The - // bridge - // method - // in - // this - // type - // will - // have - // the - // same - // signature - // as - // the - // one - // in - // the - // supertype - bridgeMethod.setAccessFlags(bridgeMethod.getAccessFlags() | 0x00000040 /* - * BRIDGE = 0x00000040 - */); - // UnresolvedType[] newParams = - // munger.getSignature().getParameterTypes(); + // The bridge method in this type will have the same signature as the one in the supertype + LazyMethodGen bridgeMethod = makeMethodGen(clazz, theBridgeMethod); + bridgeMethod.setAccessFlags(bridgeMethod.getAccessFlags() | 0x00000040 /* BRIDGE = 0x00000040 */); + // UnresolvedType[] newParams = munger.getSignature().getParameterTypes(); Type returnType = BcelWorld.makeBcelType(theBridgeMethod.getReturnType()); body = bridgeMethod.getBody(); fact = clazz.getFactory(); |