diff options
author | jhugunin <jhugunin> | 2003-07-22 20:57:17 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-07-22 20:57:17 +0000 |
commit | 026b2728aef846823419ebffceb57fe8161e3d15 (patch) | |
tree | 4388f34ab63d11eccb6a89917f0a07713f70ea61 /tests | |
parent | 27ad07f5c1a4ad27fab06e1ebb91874355d90546 (diff) | |
download | aspectj-026b2728aef846823419ebffceb57fe8161e3d15.tar.gz aspectj-026b2728aef846823419ebffceb57fe8161e3d15.zip |
tests and fix for Bugzilla Bug 39993
ajc stack trace on declaring hashcode() method in aspect
added extra error-test for using super inside an inter-type declaration on
an interface with multiple parents -- the correct parent is either
hard or impossible to determine in that case
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ajcTests.xml | 13 | ||||
-rw-r--r-- | tests/bugs/MultipleSuperCf.java | 16 | ||||
-rw-r--r-- | tests/bugs/OverridingInterfaceObjectMethod.java | 50 |
3 files changed, 79 insertions, 0 deletions
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index eed7526f9..3f01a7cb6 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -6420,4 +6420,17 @@ <compile files="SwitchInAround.java"/> <run class="SwitchInAround"/> </ajc-test> + + <ajc-test dir="bugs" pr="39993" + title="ajc stack trace on declaring hashcode() method in aspect"> + <compile files="OverridingInterfaceObjectMethod.java"/> + <run class="OverridingInterfaceObjectMethod"/> + </ajc-test> + + <ajc-test dir="bugs" + title="using super in method introduced on interface with multiple supertypes"> + <compile files="MultipleSuperCf.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> </suite> diff --git a/tests/bugs/MultipleSuperCf.java b/tests/bugs/MultipleSuperCf.java new file mode 100644 index 000000000..51404a33f --- /dev/null +++ b/tests/bugs/MultipleSuperCf.java @@ -0,0 +1,16 @@ +import org.aspectj.testing.Tester; + +interface B1 { } +interface B2 { } + +interface D extends B1, B2 {} + +aspect A { + public int B1.m() { + return 2; + } + + public int D.m() { + return super.m(); // CE even though B1.m is the only thing that makes sense + } +}
\ No newline at end of file diff --git a/tests/bugs/OverridingInterfaceObjectMethod.java b/tests/bugs/OverridingInterfaceObjectMethod.java new file mode 100644 index 000000000..d9ea38b88 --- /dev/null +++ b/tests/bugs/OverridingInterfaceObjectMethod.java @@ -0,0 +1,50 @@ +import org.aspectj.testing.Tester; + +public class OverridingInterfaceObjectMethod { + private static final int VALUE = 10; + + public static void main(String[] args) { + Identifiable i = new C(); + Tester.checkEqual(i.hashCode(), 42); //System.identityHashCode(i)); + i.setId(new Id(VALUE)); + Tester.checkEqual(i.hashCode(), VALUE); + } +} + +//TODO explore complicated inheritance hierarchies + +class C implements Identifiable {} + +interface Base { } + +interface Identifiable extends Base { + void setId(Id id); + Id getId(); +} + +class Id { + public Id(int value) { + this.value = value; + } + int value; +} + +aspect IdentifiableAspect { + private Id Identifiable.id = null; + public Id Identifiable.getId() { + return this.id; + } + public void Identifiable.setId(Id id) { + this.id = id; + } + + public int Identifiable.hashCode() { + return (this.getId() == null) + ? super.hashCode() + : this.getId().value; + } + + public int Base.hashCode() { + return 42; + } +} |