]> source.dussan.org Git - aspectj.git/commitdiff
164016:258788: testcode
authoraclement <aclement>
Tue, 6 Jan 2009 22:05:13 +0000 (22:05 +0000)
committeraclement <aclement>
Tue, 6 Jan 2009 22:05:13 +0000 (22:05 +0000)
tests/bugs164/pr164016/Code.aj [new file with mode: 0644]
tests/bugs164/pr258788/NameAware.java [new file with mode: 0644]
tests/bugs164/pr258788/NameManager.java [new file with mode: 0644]
tests/bugs164/pr258788/NameManagerImpl.java [new file with mode: 0644]
tests/bugs164/pr258788/StartClass.java [new file with mode: 0644]
tests/bugs164/pr258788/TargetClass.java [new file with mode: 0644]
tests/bugs164/pr258788/TestAspect.java [new file with mode: 0644]

diff --git a/tests/bugs164/pr164016/Code.aj b/tests/bugs164/pr164016/Code.aj
new file mode 100644 (file)
index 0000000..e60f099
--- /dev/null
@@ -0,0 +1,71 @@
+package test;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.DeclareParents;
+
+interface A {
+       void doA();
+}
+
+interface BBad extends A {
+       void doB();
+}
+
+interface BGood extends A {
+       void doB();
+       void doA();
+}
+
+class TargetBad { }
+class TargetGood { }
+
+@Aspect
+ class DeclareParentsAspect {
+
+//     @DeclareParents(value = "test.TargetGood", defaultImpl = BImplGood.class)
+ //       private BGood bGood;
+
+       @DeclareParents(value = "test.TargetBad", defaultImpl = BImplGood.class)
+       private BBad bBad;
+
+       public static class BImplGood implements BGood, BBad {
+
+               public void doB() {
+                       System.out.println("doB");
+               }
+
+               public void doA() {
+                       System.out.println("doA");
+               }
+       }
+}
+
+public class Code {
+       public static void main(String... args) { 
+/*
+               {
+                       TargetGood target = new TargetGood();
+                       BGood b = (BGood) target;
+                       b.doB();
+                       b.doA();
+               }
+*/
+               {
+                       TargetBad target = new TargetBad();
+                       BBad b = (BBad) target;
+                       b.doB();
+
+                       /*
+                       The following line is the problem.
+                       The Generated class should refer to ajc$test_DeclareParentsAspect$test_BBad
+
+                       Instead...
+
+                       Exception in thread "main" java.lang.NoSuchFieldError: ajc$test_DeclareParentsAspect$test_A
+                       at test.TargetBad.doA(TargetBad.java:1)
+                       at test.Main.main(Main.java:21)
+                       */
+                       b.doA();
+               }
+       }
+
+}
diff --git a/tests/bugs164/pr258788/NameAware.java b/tests/bugs164/pr258788/NameAware.java
new file mode 100644 (file)
index 0000000..7159a52
--- /dev/null
@@ -0,0 +1,5 @@
+package com;
+
+public interface NameAware {
+           void setName(String name);
+}
diff --git a/tests/bugs164/pr258788/NameManager.java b/tests/bugs164/pr258788/NameManager.java
new file mode 100644 (file)
index 0000000..531a9ce
--- /dev/null
@@ -0,0 +1,6 @@
+package com;
+
+public interface NameManager extends NameAware {
+           String getName();
+}
+
diff --git a/tests/bugs164/pr258788/NameManagerImpl.java b/tests/bugs164/pr258788/NameManagerImpl.java
new file mode 100644 (file)
index 0000000..bbd8e74
--- /dev/null
@@ -0,0 +1,15 @@
+package com;
+
+public class NameManagerImpl implements NameManager {
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
+
diff --git a/tests/bugs164/pr258788/StartClass.java b/tests/bugs164/pr258788/StartClass.java
new file mode 100644 (file)
index 0000000..fd25ac1
--- /dev/null
@@ -0,0 +1,19 @@
+package com;
+
+public class StartClass {
+    public static void main(String[] args) {
+        TargetClass bean = new TargetClass();
+        System.out.println("IS-A NameAware: " + (bean instanceof NameAware));
+        System.out.println("IS-A NameManager: " + (bean instanceof
+NameManager));
+        System.out.println("");
+        System.out.println("Calling get() ...");
+        ((NameManager)bean).getName();
+        System.out.println("Done.");
+        System.out.println("");
+        System.out.println("Calling set() ... ");
+        ((NameAware)bean).setName("asd");
+        System.out.println("Done.");
+    }
+}
+
diff --git a/tests/bugs164/pr258788/TargetClass.java b/tests/bugs164/pr258788/TargetClass.java
new file mode 100644 (file)
index 0000000..3e5cd0b
--- /dev/null
@@ -0,0 +1,5 @@
+package com;
+
+public class TargetClass {
+}
+
diff --git a/tests/bugs164/pr258788/TestAspect.java b/tests/bugs164/pr258788/TestAspect.java
new file mode 100644 (file)
index 0000000..c91266c
--- /dev/null
@@ -0,0 +1,12 @@
+package com;
+
+import org.aspectj.lang.annotation.*;
+
+@Aspect
+public class TestAspect {
+
+           @DeclareParents(value = "com.TargetClass", defaultImpl =
+                           NameManagerImpl.class)
+                       private NameManager nameManager;
+}
+