diff options
author | jhugunin <jhugunin> | 2003-07-23 16:45:09 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-07-23 16:45:09 +0000 |
commit | a1209dab6e3eebf46812e07fd698b4920d54d1f6 (patch) | |
tree | 6ff95b7120cdb3536a6df99247da83589061e131 | |
parent | a1bb5dae64e5e5bc3541d426d9a160ffb5fbec35 (diff) | |
download | aspectj-a1209dab6e3eebf46812e07fd698b4920d54d1f6.tar.gz aspectj-a1209dab6e3eebf46812e07fd698b4920d54d1f6.zip |
added test for Bugzilla Bug 40589
Default method impl for interface causes internal exception.
test submitted by George Harley
-rw-r--r-- | tests/ajcTests.xml | 6 | ||||
-rw-r--r-- | tests/bugs/CloneMethod.java | 58 |
2 files changed, 64 insertions, 0 deletions
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index e133841a2..b88e97da1 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -6450,4 +6450,10 @@ </compile> <run class="Test"/> </ajc-test> + + <ajc-test dir="bugs" pr="40589" + title="Default method impl for interface causes internal exception."> + <compile files="CloneMethod.java"/> + <run class="CloneMethod"/> + </ajc-test> </suite> diff --git a/tests/bugs/CloneMethod.java b/tests/bugs/CloneMethod.java new file mode 100644 index 000000000..c80bc1708 --- /dev/null +++ b/tests/bugs/CloneMethod.java @@ -0,0 +1,58 @@ +aspect AspectA { + protected interface I { + } + + declare parents : MyString implements I; + + protected Object createCloneFor(I object) { + if (object instanceof MyString) { + return new MyString(((MyString) object).toString()); + } else { + return null; + } + } + + public Object I.clone() throws CloneNotSupportedException { + return super.clone(); +// return null; + } + + public Object cloneObject(I object) { + try { + return object.clone(); + } catch (CloneNotSupportedException ex) { + return createCloneFor(object); + } + } +} + +class MyString implements Cloneable { + + protected String text; + + public MyString(String init) { + text = init; + } + + public void setText(String newText) { + text = newText; + } + + public String toString() { + return "MyString: " + text; + } +} + +public class CloneMethod { + + public static void main(String[] args) { + MyString orig1; + MyString copy1; + + orig1 = new MyString(" This is I 1"); + copy1 = (MyString) AspectA.aspectOf().cloneObject(orig1); + orig1.setText(" This is I 2"); + copy1.setText(" This is Clone 1"); + System.out.println("... done."); + } +} |