From: aclement Date: Wed, 3 Dec 2008 22:48:10 +0000 (+0000) Subject: 164016: testcode X-Git-Tag: V1_6_3rc1~67 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2c41499e77a0f11a226edf1255a7b025dd3a4131;p=aspectj.git 164016: testcode --- diff --git a/tests/bugs163/pr164016/Code.aj b/tests/bugs163/pr164016/Code.aj new file mode 100644 index 000000000..e60f09936 --- /dev/null +++ b/tests/bugs163/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(); + } + } + +}