]> source.dussan.org Git - aspectj.git/commitdiff
128664: testcode
authoraclement <aclement>
Tue, 9 Dec 2008 19:27:14 +0000 (19:27 +0000)
committeraclement <aclement>
Tue, 9 Dec 2008 19:27:14 +0000 (19:27 +0000)
tests/bugs163/pr128664/Bug.java [new file with mode: 0644]
tests/bugs163/pr128664/Bug2.java [new file with mode: 0644]

diff --git a/tests/bugs163/pr128664/Bug.java b/tests/bugs163/pr128664/Bug.java
new file mode 100644 (file)
index 0000000..92eb248
--- /dev/null
@@ -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 (file)
index 0000000..eb6878f
--- /dev/null
@@ -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++;
+        }
+}