diff options
author | acolyer <acolyer> | 2005-09-02 17:12:43 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-09-02 17:12:43 +0000 |
commit | df46c6f728502a74b2d042a0a955eab1326ba76a (patch) | |
tree | 5d0e149d509e85b685f532aee75c984afd2e09f1 | |
parent | 2c88c598b950136bf54376eecbf58f14a19666c4 (diff) | |
download | aspectj-df46c6f728502a74b2d042a0a955eab1326ba76a.tar.gz aspectj-df46c6f728502a74b2d042a0a955eab1326ba76a.zip |
tests and fix for pr99125 - duplicate members in interfaces after binary weaving
-rw-r--r-- | tests/bugs150/pr99125/Aspects.aj | 19 | ||||
-rw-r--r-- | tests/bugs150/pr99125/p/I.java | 6 | ||||
-rw-r--r-- | tests/bugs150/pr99125/p/J.java | 4 | ||||
-rw-r--r-- | tests/bugs150/pr99125/p/pr99125.aj | 10 | ||||
-rw-r--r-- | tests/bugs150/pr99125/p2/pr99125.aj | 11 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 4 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 12 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java | 6 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java | 14 |
9 files changed, 83 insertions, 3 deletions
diff --git a/tests/bugs150/pr99125/Aspects.aj b/tests/bugs150/pr99125/Aspects.aj new file mode 100644 index 000000000..96fa6b4b6 --- /dev/null +++ b/tests/bugs150/pr99125/Aspects.aj @@ -0,0 +1,19 @@ +import p.*; + +abstract aspect X { + + public void I.bar() {} + + public void pr99125.aMethod() {} + +} + +aspect Y extends X { + + public void I.goo() {}; + + public void I.foo() { System.out.println("you got me"); } + +} + +aspect Z extends X {}
\ No newline at end of file diff --git a/tests/bugs150/pr99125/p/I.java b/tests/bugs150/pr99125/p/I.java new file mode 100644 index 000000000..fbbd7ace4 --- /dev/null +++ b/tests/bugs150/pr99125/p/I.java @@ -0,0 +1,6 @@ +package p; +public interface I { + + void foo(); + +}
\ No newline at end of file diff --git a/tests/bugs150/pr99125/p/J.java b/tests/bugs150/pr99125/p/J.java new file mode 100644 index 000000000..fc1331005 --- /dev/null +++ b/tests/bugs150/pr99125/p/J.java @@ -0,0 +1,4 @@ +package p; + +public +interface J extends I {}
\ No newline at end of file diff --git a/tests/bugs150/pr99125/p/pr99125.aj b/tests/bugs150/pr99125/p/pr99125.aj new file mode 100644 index 000000000..b4969d059 --- /dev/null +++ b/tests/bugs150/pr99125/p/pr99125.aj @@ -0,0 +1,10 @@ +package p; +public class pr99125 implements J { + + public static void main(String[] args) { + new pr99125().foo(); + } + + public void foo() {} + +} diff --git a/tests/bugs150/pr99125/p2/pr99125.aj b/tests/bugs150/pr99125/p2/pr99125.aj new file mode 100644 index 000000000..4f860c301 --- /dev/null +++ b/tests/bugs150/pr99125/p2/pr99125.aj @@ -0,0 +1,11 @@ +package p; +public class pr99125 implements J { + + public static void main(String[] args) { + new pr99125().foo(); + } + + public void foo() {} + + public void aMethod() {} +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 5db8119d1..57642f9bd 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -382,6 +382,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("unused private pointcuts"); } + public void testITDOnInterfaceWithExistingMember() { + runTest("itd interface method already existing on interface"); + } + // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index aba23f729..e805601bf 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -473,6 +473,18 @@ <compile files="pr101606.aj" options="-warn:unusedPrivate"> </compile> </ajc-test> + + <ajc-test dir="bugs150/pr99125" pr="99125" title="itd interface method already existing on interface"> + <compile files="p/pr99125.aj,p/I.java,p/J.java" options="-1.5"> + </compile> + <compile files="Aspects.aj" options="-inpath p"/> + <run class="p.pr99125"/> + <compile files="p2/pr99125.aj,p/I.java,p/J.java"/> <!-- actually in package p, introduces incompatible change --> + <compile files="Aspects.aj" options="-inpath p"> + <message kind="error" line="7" text="inter-type declaration from X conflicts with existing member"/> + </compile> + </ajc-test> + <!-- ============================================================================ --> <!-- ============================================================================ --> diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index e677685ed..8100a4d92 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -733,6 +733,12 @@ public class BcelTypeMunger extends ConcreteTypeMunger { return false; } + if (onInterface && gen.getLazyMethodGen(unMangledInterMethod.getName(), unMangledInterMethod.getSignature(),true) != null) { + // this is ok, we could be providing the default implementation of a method + // that the target has already declared + return false; + } + if (onType.equals(gen.getType())) { ResolvedMember mangledInterMethod = AjcMemberMaker.interMethod(unMangledInterMethod, aspectType, onInterface); diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java index 887b1a16b..f75ec647f 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java @@ -1126,18 +1126,26 @@ public final class LazyClassGen { } public LazyMethodGen getLazyMethodGen(Member m) { - return getLazyMethodGen(m.getName(), m.getSignature()); + return getLazyMethodGen(m.getName(), m.getSignature(),false); } public LazyMethodGen getLazyMethodGen(String name, String signature) { + return getLazyMethodGen(name,signature,false); + } + + public LazyMethodGen getLazyMethodGen(String name, String signature,boolean allowMissing) { for (Iterator i = methodGens.iterator(); i.hasNext();) { LazyMethodGen gen = (LazyMethodGen) i.next(); if (gen.getName().equals(name) && gen.getSignature().equals(signature)) return gen; } - throw new BCException("Class " + this.getName() + " does not have a method " - + name + " with signature " + signature); + if (!allowMissing) { + throw new BCException("Class " + this.getName() + " does not have a method " + + name + " with signature " + signature); + } + + return null; } public void forcePublic() { |