]> source.dussan.org Git - aspectj.git/commitdiff
382189 and 382435
authorAndy Clement <andrew.clement@gmail.com>
Sat, 16 Jun 2012 00:42:25 +0000 (17:42 -0700)
committerAndy Clement <andrew.clement@gmail.com>
Sat, 16 Jun 2012 00:42:25 +0000 (17:42 -0700)
40 files changed:
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
tests/bugs170/pr382189/covbug/A.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/A_ITD.aj [new file with mode: 0644]
tests/bugs170/pr382189/covbug/B.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/SuperA.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/SuperB.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/A.class [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/A.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/A_ITD.aj [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/B.class [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/B.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/SuperA.class [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/SuperA.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/SuperB.class [new file with mode: 0644]
tests/bugs170/pr382189/covbug/cc/covbug/SuperB.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/pj/A.class [new file with mode: 0644]
tests/bugs170/pr382189/covbug/pj/B.class [new file with mode: 0644]
tests/bugs170/pr382189/covbug/pj/Foo.java [new file with mode: 0644]
tests/bugs170/pr382189/covbug/pj/SuperA.class [new file with mode: 0644]
tests/bugs170/pr382189/covbug/pj/SuperB.class [new file with mode: 0644]
tests/bugs170/pr382189/one/A.java [new file with mode: 0644]
tests/bugs170/pr382189/one/A_ITD.aj [new file with mode: 0644]
tests/bugs170/pr382189/one/B.java [new file with mode: 0644]
tests/bugs170/pr382189/one/SuperA.java [new file with mode: 0644]
tests/bugs170/pr382189/one/SuperB.java [new file with mode: 0644]
tests/bugs170/pr382189/three/A.java [new file with mode: 0644]
tests/bugs170/pr382189/three/A_ITD.aj [new file with mode: 0644]
tests/bugs170/pr382189/three/B.java [new file with mode: 0644]
tests/bugs170/pr382189/three/SuperA.java [new file with mode: 0644]
tests/bugs170/pr382189/three/SuperB.java [new file with mode: 0644]
tests/bugs170/pr382189/two/A.java [new file with mode: 0644]
tests/bugs170/pr382189/two/A_ITD.aj [new file with mode: 0644]
tests/bugs170/pr382189/two/B.java [new file with mode: 0644]
tests/bugs170/pr382189/two/SuperA.java [new file with mode: 0644]
tests/bugs170/pr382189/two/SuperB.java [new file with mode: 0644]
tests/bugs170/pr382435/one/bug/A.java [new file with mode: 0644]
tests/bugs170/pr382435/two/bug/A.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java
tests/src/org/aspectj/systemtest/ajc170/ajc170.xml
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java

index 0659dfc1e220e13ae2f5299a23b97a07d2045654..a87a698712e07808858eb5869ee9a41be4a2b9fc 100644 (file)
@@ -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 (file)
index 0000000..1bf20c5
--- /dev/null
@@ -0,0 +1,2 @@
+package covbug;\r
+public class A {  }\r
diff --git a/tests/bugs170/pr382189/covbug/A_ITD.aj b/tests/bugs170/pr382189/covbug/A_ITD.aj
new file mode 100644 (file)
index 0000000..5cf1a73
--- /dev/null
@@ -0,0 +1,12 @@
+package covbug;\r
+\r
+\r
+public privileged aspect A_ITD {\r
+       declare parents: A extends SuperA<String>;\r
+\r
+       \r
+       public B A.getSomeB(SuperB<String> b){\r
+               return null;\r
+       }\r
+\r
+}\r
diff --git a/tests/bugs170/pr382189/covbug/B.java b/tests/bugs170/pr382189/covbug/B.java
new file mode 100644 (file)
index 0000000..1184552
--- /dev/null
@@ -0,0 +1,3 @@
+package covbug;\r
+
+public class B extends SuperB<String> { }\r
diff --git a/tests/bugs170/pr382189/covbug/SuperA.java b/tests/bugs170/pr382189/covbug/SuperA.java
new file mode 100644 (file)
index 0000000..288b9f9
--- /dev/null
@@ -0,0 +1,6 @@
+package covbug;\r
+import java.util.List;\r
+\r
+public abstract class SuperA<T> {\r
+       public abstract SuperB<T> getSomeB(SuperB<T> b);\r
+}\r
diff --git a/tests/bugs170/pr382189/covbug/SuperB.java b/tests/bugs170/pr382189/covbug/SuperB.java
new file mode 100644 (file)
index 0000000..8a6c2c2
--- /dev/null
@@ -0,0 +1,3 @@
+package covbug;\r
+\r
+public class SuperB<T> { }\r
diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/A.class b/tests/bugs170/pr382189/covbug/cc/covbug/A.class
new file mode 100644 (file)
index 0000000..59a59b7
Binary files /dev/null and b/tests/bugs170/pr382189/covbug/cc/covbug/A.class differ
diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/A.java b/tests/bugs170/pr382189/covbug/cc/covbug/A.java
new file mode 100644 (file)
index 0000000..1c0499f
--- /dev/null
@@ -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 (file)
index 0000000..5cf1a73
--- /dev/null
@@ -0,0 +1,12 @@
+package covbug;\r
+\r
+\r
+public privileged aspect A_ITD {\r
+       declare parents: A extends SuperA<String>;\r
+\r
+       \r
+       public B A.getSomeB(SuperB<String> b){\r
+               return null;\r
+       }\r
+\r
+}\r
diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/B.class b/tests/bugs170/pr382189/covbug/cc/covbug/B.class
new file mode 100644 (file)
index 0000000..91debf8
Binary files /dev/null and b/tests/bugs170/pr382189/covbug/cc/covbug/B.class differ
diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/B.java b/tests/bugs170/pr382189/covbug/cc/covbug/B.java
new file mode 100644 (file)
index 0000000..cdfd1f7
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..d5ba823
Binary files /dev/null and b/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.class differ
diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.java b/tests/bugs170/pr382189/covbug/cc/covbug/SuperA.java
new file mode 100644 (file)
index 0000000..dfb721b
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..cd3b522
Binary files /dev/null and b/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.class differ
diff --git a/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.java b/tests/bugs170/pr382189/covbug/cc/covbug/SuperB.java
new file mode 100644 (file)
index 0000000..2f5167d
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..4f315b4
Binary files /dev/null and b/tests/bugs170/pr382189/covbug/pj/A.class differ
diff --git a/tests/bugs170/pr382189/covbug/pj/B.class b/tests/bugs170/pr382189/covbug/pj/B.class
new file mode 100644 (file)
index 0000000..11e52e8
Binary files /dev/null and b/tests/bugs170/pr382189/covbug/pj/B.class differ
diff --git a/tests/bugs170/pr382189/covbug/pj/Foo.java b/tests/bugs170/pr382189/covbug/pj/Foo.java
new file mode 100644 (file)
index 0000000..d8e1721
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..93153a4
Binary files /dev/null and b/tests/bugs170/pr382189/covbug/pj/SuperA.class differ
diff --git a/tests/bugs170/pr382189/covbug/pj/SuperB.class b/tests/bugs170/pr382189/covbug/pj/SuperB.class
new file mode 100644 (file)
index 0000000..7f4c4e5
Binary files /dev/null and b/tests/bugs170/pr382189/covbug/pj/SuperB.class differ
diff --git a/tests/bugs170/pr382189/one/A.java b/tests/bugs170/pr382189/one/A.java
new file mode 100644 (file)
index 0000000..edd16a5
--- /dev/null
@@ -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 (file)
index 0000000..7c5be5c
--- /dev/null
@@ -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 (file)
index 0000000..b32fa4e
--- /dev/null
@@ -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 (file)
index 0000000..09755a1
--- /dev/null
@@ -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 (file)
index 0000000..a5098aa
--- /dev/null
@@ -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 (file)
index 0000000..c24a6f6
--- /dev/null
@@ -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 (file)
index 0000000..39b5597
--- /dev/null
@@ -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 (file)
index 0000000..db22693
--- /dev/null
@@ -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 (file)
index 0000000..09755a1
--- /dev/null
@@ -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 (file)
index 0000000..a5098aa
--- /dev/null
@@ -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 (file)
index 0000000..9f4b93d
--- /dev/null
@@ -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 (file)
index 0000000..39b5597
--- /dev/null
@@ -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 (file)
index 0000000..b32fa4e
--- /dev/null
@@ -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 (file)
index 0000000..09755a1
--- /dev/null
@@ -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 (file)
index 0000000..a5098aa
--- /dev/null
@@ -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 (file)
index 0000000..a331bcc
--- /dev/null
@@ -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 (file)
index 0000000..f4d08be
--- /dev/null
@@ -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;
+       }
+}
index 3585e782a497996dda82222eff31db20bc1eced8..c9b1a7377157c2dcf26a06858f82b406cc0a8f27 100644 (file)
@@ -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");
index 05ebd0ee234dc6cf8de9b900bfc84c616b9fc82a..1413eae398d84bbed21daf6169b27e93ffd49f9b 100644 (file)
                </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">
index ac9bacf841d675fcecd2dc08d477935058a92c74..2ae4ac91a141d78fe3b0f3f8ea5deed393eaddc9 100644 (file)
@@ -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();