]> source.dussan.org Git - aspectj.git/commitdiff
added test for Bugzilla Bug 40589
authorjhugunin <jhugunin>
Wed, 23 Jul 2003 16:45:09 +0000 (16:45 +0000)
committerjhugunin <jhugunin>
Wed, 23 Jul 2003 16:45:09 +0000 (16:45 +0000)
   Default method impl for interface causes internal exception.

test submitted by George Harley

tests/ajcTests.xml
tests/bugs/CloneMethod.java [new file with mode: 0644]

index e133841a25373c0a3621ca2be955d7d31c76573c..b88e97da101bd8af9b6d2d42a6d06b0b30b435ce 100644 (file)
         </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 (file)
index 0000000..c80bc17
--- /dev/null
@@ -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.");
+       }
+}