From: aclement Date: Tue, 6 Jan 2009 22:05:13 +0000 (+0000) Subject: 164016:258788: testcode X-Git-Tag: pre268419~246 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=10f564c53f96eadd15817b75d114a43460cef861;p=aspectj.git 164016:258788: testcode --- diff --git a/tests/bugs164/pr164016/Code.aj b/tests/bugs164/pr164016/Code.aj new file mode 100644 index 000000000..e60f09936 --- /dev/null +++ b/tests/bugs164/pr164016/Code.aj @@ -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 index 000000000..7159a520c --- /dev/null +++ b/tests/bugs164/pr258788/NameAware.java @@ -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 index 000000000..531a9cef2 --- /dev/null +++ b/tests/bugs164/pr258788/NameManager.java @@ -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 index 000000000..bbd8e743b --- /dev/null +++ b/tests/bugs164/pr258788/NameManagerImpl.java @@ -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 index 000000000..fd25ac169 --- /dev/null +++ b/tests/bugs164/pr258788/StartClass.java @@ -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 index 000000000..3e5cd0b6a --- /dev/null +++ b/tests/bugs164/pr258788/TargetClass.java @@ -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 index 000000000..c91266c9c --- /dev/null +++ b/tests/bugs164/pr258788/TestAspect.java @@ -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; +} +