]> source.dussan.org Git - aspectj.git/commitdiff
Fix 526734 - Incorrect generic override decp validation when binary weaving
authorAndy Clement <aclement@pivotal.io>
Wed, 1 Nov 2017 22:08:27 +0000 (15:08 -0700)
committerAndy Clement <aclement@pivotal.io>
Wed, 1 Nov 2017 22:31:10 +0000 (15:31 -0700)
tests/bugs1813/generics/A.java [new file with mode: 0644]
tests/bugs1813/generics/AlreadyImplementsA.java [new file with mode: 0644]
tests/bugs1813/generics/BaseI.java [new file with mode: 0644]
tests/bugs1813/generics/BaseT.java [new file with mode: 0644]
tests/bugs1813/generics/BindInterfaceA.aj [new file with mode: 0644]
tests/bugs1813/generics/ConcreteIImpl.java [new file with mode: 0644]
tests/bugs1813/generics/ConcreteTImpl.java [new file with mode: 0644]
tests/bugs1813/generics/Runner.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java
tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java

diff --git a/tests/bugs1813/generics/A.java b/tests/bugs1813/generics/A.java
new file mode 100644 (file)
index 0000000..85ec82e
--- /dev/null
@@ -0,0 +1,8 @@
+import java.util.List;
+
+
+public interface A<T extends BaseT, I extends BaseI> {
+
+    public T setInputs(List<I> inputs);
+
+}
\ No newline at end of file
diff --git a/tests/bugs1813/generics/AlreadyImplementsA.java b/tests/bugs1813/generics/AlreadyImplementsA.java
new file mode 100644 (file)
index 0000000..56f650d
--- /dev/null
@@ -0,0 +1,15 @@
+
+import java.util.List;
+
+
+public class AlreadyImplementsA {
+
+
+    public ConcreteTImpl setInputs(List<ConcreteIImpl> inputs) {
+        return null;
+    }
+
+
+
+
+}
\ No newline at end of file
diff --git a/tests/bugs1813/generics/BaseI.java b/tests/bugs1813/generics/BaseI.java
new file mode 100644 (file)
index 0000000..31f9758
--- /dev/null
@@ -0,0 +1,7 @@
+
+
+public interface BaseI {
+
+
+
+}
\ No newline at end of file
diff --git a/tests/bugs1813/generics/BaseT.java b/tests/bugs1813/generics/BaseT.java
new file mode 100644 (file)
index 0000000..72046e9
--- /dev/null
@@ -0,0 +1,4 @@
+
+public interface BaseT {
+
+}
\ No newline at end of file
diff --git a/tests/bugs1813/generics/BindInterfaceA.aj b/tests/bugs1813/generics/BindInterfaceA.aj
new file mode 100644 (file)
index 0000000..2d3e569
--- /dev/null
@@ -0,0 +1,8 @@
+
+
+public aspect BindInterfaceA {
+
+    declare parents: AlreadyImplementsA implements A<ConcreteTImpl,ConcreteIImpl>;
+
+
+}
diff --git a/tests/bugs1813/generics/ConcreteIImpl.java b/tests/bugs1813/generics/ConcreteIImpl.java
new file mode 100644 (file)
index 0000000..3cbdac1
--- /dev/null
@@ -0,0 +1,5 @@
+
+
+public class ConcreteIImpl implements BaseI {
+
+}
diff --git a/tests/bugs1813/generics/ConcreteTImpl.java b/tests/bugs1813/generics/ConcreteTImpl.java
new file mode 100644 (file)
index 0000000..aba55be
--- /dev/null
@@ -0,0 +1,6 @@
+
+
+public class ConcreteTImpl implements BaseT {
+
+
+}
diff --git a/tests/bugs1813/generics/Runner.java b/tests/bugs1813/generics/Runner.java
new file mode 100644 (file)
index 0000000..6d4468b
--- /dev/null
@@ -0,0 +1,7 @@
+public class Runner {
+       public static void main(String[] argv) {
+               if (new AlreadyImplementsA() instanceof A) {
+                       System.out.println("ok");
+               }
+       }
+}
index 4e6013507a51a882c85e6b3243556a807314dfad..80729f8942327ef4bde6840c8a0acb63dcb166a2 100644 (file)
@@ -63,6 +63,7 @@ public class Ajc1811Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                
                // public Outer<String>.Inner m2() { ... }
        }
+       
 //     
 //     public void testMultiArgs_509235() {
 //             runTest("multiargs");
@@ -72,6 +73,12 @@ public class Ajc1811Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 //             runTest("multiargs - no ellipsis");
 //     }
 
+       // 1.8.13:
+
+       public void testAjcGenerics() {
+               runTest("generics");
+       }
+
        // ---
 
        public static Test suite() {
index f4e321e5cc4d1cb028bdea3193c6509a3d2d5670..fe59c3595bfbe47e81606a019cd5ab34a4773787 100644 (file)
@@ -6,6 +6,23 @@
                <compile options="-1.8" files="Code.java"/>
        </ajc-test>
        
+       <ajc-test dir="bugs1813/generics" title="generics">
+               <!-- this order works reliably -->
+               <compile options="-1.8 -showWeaveInfo" files="A.java AlreadyImplementsA.java BaseI.java BaseT.java BindInterfaceA.aj ConcreteIImpl.java ConcreteTImpl.java Runner.java">
+               <message kind="weave" text="Extending interface set for type 'AlreadyImplementsA' (AlreadyImplementsA.java) to include 'A&lt;ConcreteTImpl,ConcreteIImpl&gt;' (BindInterfaceA.aj)"/>
+               </compile>
+       
+               <!-- this order was failing -->
+               <compile options="-1.8 -showWeaveInfo" files="AlreadyImplementsA.java BaseI.java BaseT.java BindInterfaceA.aj ConcreteIImpl.java ConcreteTImpl.java A.java Runner.java ">
+               <message kind="weave" text="Extending interface set for type 'AlreadyImplementsA' (AlreadyImplementsA.java) to include 'A&lt;ConcreteTImpl,ConcreteIImpl&gt;' (BindInterfaceA.aj)"/>
+               </compile>
+               <run class="Runner">
+               <stdout>
+               <line text="ok"/>
+               </stdout>
+               </run>
+       </ajc-test>     
+
        <ajc-test dir="bugs1811/509235" title="multiargs">
                <compile options="-1.8" files="Code.java"/>
                <run class="Code">
index 9768cb9e4f274b6ec6a6e5f603b57bc17c78b2fa..c82c352ae3f93fa64d54b72994b583ace46e6e33 100644 (file)
@@ -352,8 +352,21 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                                                                        && targetMethod.getBackingGenericMember().getParameterSignature().equals(newParentMethodSig)) {
                                                                discoveredImpl = targetMethod;
                                                        } else if (newParentMethod.hasBackingGenericMember()) {
-                                                               if (newParentMethod.getBackingGenericMember().getParameterSignature().equals(targetMethodSignature)) {
+                                                               if (newParentMethod.getBackingGenericMember().getParameterSignature().equals(targetMethodSignature)) { // newParentMethod.getBackingGenericMember().getParameterSignature gives: (Pjava/util/List<TI;>;)  targetMethodSignature= (Ljava/util/List;)
                                                                        discoveredImpl = targetMethod;
+                                                               } else if (targetMethod instanceof BcelMethod) {
+                                                                       // BcelMethod does not have backing generic member set (need to investigate why). For now, special case here:
+                                                                       UnresolvedType[] targetMethodGenericParameterTypes = targetMethod.getGenericParameterTypes();
+                                                                       if (targetMethodGenericParameterTypes !=null) {
+                                                                               StringBuilder b = new StringBuilder("(");
+                                                                               for (UnresolvedType p: targetMethodGenericParameterTypes) {
+                                                                                       b.append(p.getSignature());
+                                                                               }
+                                                                               b.append(')');
+                                                                               if (b.toString().equals(newParentMethodSig)) {
+                                                                                       discoveredImpl = targetMethod;
+                                                                               }
+                                                                       }
                                                                }
                                                        }
                                                }