aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs151
diff options
context:
space:
mode:
authoraclement <aclement>2006-03-29 11:41:39 +0000
committeraclement <aclement>2006-03-29 11:41:39 +0000
commite05ab26570eeb1776836d67e980c37e0813e30e3 (patch)
tree2df8a29d1e469caf0f5aaaf7591dd42bb0dc4ee8 /tests/bugs151
parent09406a36994865a841d9b40dff734975dd75f4d2 (diff)
downloadaspectj-e05ab26570eeb1776836d67e980c37e0813e30e3.tar.gz
aspectj-e05ab26570eeb1776836d67e980c37e0813e30e3.zip
test and fix for @DeclareParents problem where the target was "@Coloured *" - fix was to resolve the typepattern
Diffstat (limited to 'tests/bugs151')
-rw-r--r--tests/bugs151/atDecp/case1/MainClass.java44
-rw-r--r--tests/bugs151/atDecp/case2/MainClass.java46
2 files changed, 90 insertions, 0 deletions
diff --git a/tests/bugs151/atDecp/case1/MainClass.java b/tests/bugs151/atDecp/case1/MainClass.java
new file mode 100644
index 000000000..ab58d8c8a
--- /dev/null
+++ b/tests/bugs151/atDecp/case1/MainClass.java
@@ -0,0 +1,44 @@
+package moody;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.DeclareParents;
+
+enum Mood { HAPPY, SAD, JOLLY, GRUMPY }
+
+class AnnotationMoodImplementor { }
+
+
+
+@Aspect
+class AnnotationMoodIndicator {
+
+ public interface Moody {
+ Mood getMood();
+ void setMood(Mood mood);
+ }
+
+ public static class MoodyImpl implements Moody {
+ private Mood mood = Mood.HAPPY;
+
+ public Mood getMood() { return mood; }
+ public void setMood(Mood mood) { this.mood = mood; }
+ }
+
+ @DeclareParents(value="moody.AnnotationMoodImplementor",defaultImpl=MoodyImpl.class)
+ private Moody implementedInterface;
+}
+
+
+
+public class MainClass {
+ public static void main(String[] args) {
+ AnnotationMoodImplementor ami0 = new AnnotationMoodImplementor();
+ AnnotationMoodImplementor ami1 = new AnnotationMoodImplementor();
+
+ System.err.println("ami0's mood is " + ((AnnotationMoodIndicator.Moody) ami0).getMood());
+ ((AnnotationMoodIndicator.Moody) ami1).setMood(Mood.JOLLY);
+ System.err.println("ami1's mood is now " + ((AnnotationMoodIndicator.Moody) ami1).getMood());
+ System.err.println("ami0's mood is still " + ((AnnotationMoodIndicator.Moody) ami0).getMood());
+ }
+}
+
diff --git a/tests/bugs151/atDecp/case2/MainClass.java b/tests/bugs151/atDecp/case2/MainClass.java
new file mode 100644
index 000000000..7f33bbfae
--- /dev/null
+++ b/tests/bugs151/atDecp/case2/MainClass.java
@@ -0,0 +1,46 @@
+package moody;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.DeclareParents;
+import java.lang.annotation.*;
+
+enum Mood { HAPPY, SAD, JOLLY, GRUMPY }
+
+@Retention(RetentionPolicy.RUNTIME) @interface Coloured {}
+
+@Coloured
+class AnnotationMoodImplementor { }
+
+@Aspect
+class AnnotationMoodIndicator {
+
+ public interface Moody {
+ Mood getMood();
+ void setMood(Mood mood);
+ }
+
+ public static class MoodyImpl implements Moody {
+ private Mood mood = Mood.HAPPY;
+
+ public Mood getMood() { return mood; }
+ public void setMood(Mood mood) { this.mood = mood; }
+ }
+
+ @DeclareParents(value="@Coloured *",defaultImpl=MoodyImpl.class) // Choosing types by annotation
+ private Moody implementedInterface;
+}
+
+
+
+public class MainClass {
+ public static void main(String[] args) {
+ AnnotationMoodImplementor ami0 = new AnnotationMoodImplementor();
+ AnnotationMoodImplementor ami1 = new AnnotationMoodImplementor();
+
+ System.err.println("ami0's mood is " + ((AnnotationMoodIndicator.Moody) ami0).getMood());
+ ((AnnotationMoodIndicator.Moody) ami1).setMood(Mood.JOLLY);
+ System.err.println("ami1's mood is now " + ((AnnotationMoodIndicator.Moody) ami1).getMood());
+ System.err.println("ami0's mood is still " + ((AnnotationMoodIndicator.Moody) ami0).getMood());
+ }
+}
+