diff options
author | Andy Clement <aclement@pivotal.io> | 2016-07-29 10:05:50 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2016-07-29 10:05:50 -0700 |
commit | 87856659869b9dbf72e1b329986fb2d727cfad18 (patch) | |
tree | be703a38baedd823689b7279e7641c19abb2dee6 /tests/src | |
parent | 784906d2ee0cb1b432a9aff6973c12cfd865db6e (diff) | |
download | aspectj-87856659869b9dbf72e1b329986fb2d727cfad18.tar.gz aspectj-87856659869b9dbf72e1b329986fb2d727cfad18.zip |
Fix ambiguous binding problem on anonymous types
If an anonymous class calls a method ITD'd onto one of its own
supertypes (e.g. new A() { xx(null); }) then it can be reported
as an ambiguous method invocation on Java8. There is different
handling for Java8 that is revealing an issue. The intertype
method declarations are recorded in a member finder attached to the
target type (A in this case). When the local type binding is
built it gets all the methods from supertypes added to it - this
unfortunately includes the ITD method. Then later when something
asks for all 'xx' methods on A, it finds the ITD method from when
A was constructed and an additional copy from the member finder.
The quick fix is for the member finder to use a set rather than
list when answering 'what are the xx methods'. If this proves
a problem down the line the deeper fix would be to avoid including
ITDs when the local type binding is built.
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java | 8 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java index cff7a3b7b..3af4bb79c 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java @@ -34,6 +34,14 @@ public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("indy"); } + public void testAmbigMessage17() throws Exception { + runTest("ambiguous message - 17"); + } + + public void testAmbigMessage18() throws Exception { + runTest("ambiguous message - 18"); + } + // http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6 public void testInnerClassesAttributeStructure_493554() throws Exception { runTest("pertarget"); diff --git a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml index dd4237d22..e53b8aabe 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml +++ b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml @@ -11,5 +11,12 @@ <run class="example.kusedep.Cmd"></run> </ajc-test> + <ajc-test dir="bugs1810/ambig" title="ambiguous message - 18"> + <compile options="-1.8" files="X.java"/> + </ajc-test> + <ajc-test dir="bugs1810/ambig" title="ambiguous message - 17"> + <compile options="-1.7" files="X.java"/> + </ajc-test> + </suite> |