From: Andy Clement Date: Wed, 1 Nov 2017 22:08:27 +0000 (-0700) Subject: Fix 526734 - Incorrect generic override decp validation when binary weaving X-Git-Tag: V1_8_13~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=01a2cbe1124e323131114e365bac99563c8c791d;p=aspectj.git Fix 526734 - Incorrect generic override decp validation when binary weaving --- diff --git a/tests/bugs1813/generics/A.java b/tests/bugs1813/generics/A.java new file mode 100644 index 000000000..85ec82ea2 --- /dev/null +++ b/tests/bugs1813/generics/A.java @@ -0,0 +1,8 @@ +import java.util.List; + + +public interface A { + + public T setInputs(List 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 index 000000000..56f650d03 --- /dev/null +++ b/tests/bugs1813/generics/AlreadyImplementsA.java @@ -0,0 +1,15 @@ + +import java.util.List; + + +public class AlreadyImplementsA { + + + public ConcreteTImpl setInputs(List 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 index 000000000..31f975853 --- /dev/null +++ b/tests/bugs1813/generics/BaseI.java @@ -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 index 000000000..72046e956 --- /dev/null +++ b/tests/bugs1813/generics/BaseT.java @@ -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 index 000000000..2d3e56965 --- /dev/null +++ b/tests/bugs1813/generics/BindInterfaceA.aj @@ -0,0 +1,8 @@ + + +public aspect BindInterfaceA { + + declare parents: AlreadyImplementsA implements A; + + +} diff --git a/tests/bugs1813/generics/ConcreteIImpl.java b/tests/bugs1813/generics/ConcreteIImpl.java new file mode 100644 index 000000000..3cbdac163 --- /dev/null +++ b/tests/bugs1813/generics/ConcreteIImpl.java @@ -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 index 000000000..aba55be3a --- /dev/null +++ b/tests/bugs1813/generics/ConcreteTImpl.java @@ -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 index 000000000..6d4468b0f --- /dev/null +++ b/tests/bugs1813/generics/Runner.java @@ -0,0 +1,7 @@ +public class Runner { + public static void main(String[] argv) { + if (new AlreadyImplementsA() instanceof A) { + System.out.println("ok"); + } + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java index f354bd9e4..6e1f9d052 100644 --- a/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java @@ -63,6 +63,7 @@ public class Ajc1811Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // public Outer.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() { diff --git a/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml b/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml index f4e321e5c..fe59c3595 100644 --- a/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml +++ b/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml @@ -6,6 +6,23 @@ + + + + + + + + + + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index 9768cb9e4..c82c352ae 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -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;) 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; + } + } } } }