aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs163
diff options
context:
space:
mode:
authoraclement <aclement>2008-12-09 19:27:14 +0000
committeraclement <aclement>2008-12-09 19:27:14 +0000
commit5621f148e957cec57c319c8c9508167134a806f0 (patch)
treee2c1bd9d98936ecc35a38ffd3c1663fb4be3aa1d /tests/bugs163
parentf1a83b5f2ba583e3c18542f962b569847a863844 (diff)
downloadaspectj-5621f148e957cec57c319c8c9508167134a806f0.tar.gz
aspectj-5621f148e957cec57c319c8c9508167134a806f0.zip
128664: testcode
Diffstat (limited to 'tests/bugs163')
-rw-r--r--tests/bugs163/pr128664/Bug.java41
-rw-r--r--tests/bugs163/pr128664/Bug2.java30
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/bugs163/pr128664/Bug.java b/tests/bugs163/pr128664/Bug.java
new file mode 100644
index 000000000..92eb248e5
--- /dev/null
+++ b/tests/bugs163/pr128664/Bug.java
@@ -0,0 +1,41 @@
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+public class Bug {
+ public static void main(String[] args) {
+ MonitorMyAnnotationExecution.aspectOf().executionCount = 0;
+ new ClassImplementingInterfaceWithInheritedAnnotation();
+ if (MonitorMyAnnotationExecution.aspectOf().executionCount!=1) {
+ throw new RuntimeException();
+ }
+
+ MonitorMyAnnotationExecution.aspectOf().executionCount = 0;
+ new ClassExtendingClassWithInheritedAnnotation();
+ // Expecting 2, one for derived and one for base class ctor execution
+ if (MonitorMyAnnotationExecution.aspectOf().executionCount!=2) {
+ throw new RuntimeException();
+ }
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@interface InheritedAnnotation { }
+
+@InheritedAnnotation
+interface InterfaceWithInheritedAnnotation { }
+
+@InheritedAnnotation class ClassWithInheritedAnnotation { }
+
+class ClassImplementingInterfaceWithInheritedAnnotation implements InterfaceWithInheritedAnnotation { }
+
+class ClassExtendingClassWithInheritedAnnotation extends ClassWithInheritedAnnotation { }
+
+aspect MonitorMyAnnotationExecution {
+ int executionCount;
+
+ before() : execution((@InheritedAnnotation *)+.new(..)) && !within(Monitor*) && !within(Bug) {
+ executionCount++;
+ }
+}
diff --git a/tests/bugs163/pr128664/Bug2.java b/tests/bugs163/pr128664/Bug2.java
new file mode 100644
index 000000000..eb6878f20
--- /dev/null
+++ b/tests/bugs163/pr128664/Bug2.java
@@ -0,0 +1,30 @@
+import java.lang.annotation.*;
+
+public class Bug2 {
+ public static void main(String[] args) {
+ MonitorMyAnnotationExecution.aspectOf().executionCount = 0;
+ new ClassImplementingSubInterfaceWithInheritedAnnotation();
+ if (MonitorMyAnnotationExecution.aspectOf().executionCount!=1) {
+ throw new RuntimeException();
+ }
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@interface InheritedAnnotation { }
+
+@InheritedAnnotation
+interface InterfaceWithInheritedAnnotation { }
+
+interface SubInterfaceOfInterfaceWithInheritedAnnotation extends InterfaceWithInheritedAnnotation {}
+
+class ClassImplementingSubInterfaceWithInheritedAnnotation implements SubInterfaceOfInterfaceWithInheritedAnnotation { }
+
+aspect MonitorMyAnnotationExecution {
+ int executionCount;
+
+ before() : execution((@InheritedAnnotation *)+.new(..)) && !within(Monitor*) && !within(Bug2) {
+ executionCount++;
+ }
+}