summaryrefslogtreecommitdiffstats
path: root/tests/java5/annotations
diff options
context:
space:
mode:
authoracolyer <acolyer>2004-12-09 14:02:47 +0000
committeracolyer <acolyer>2004-12-09 14:02:47 +0000
commit592467e8a30dac18931ffed58a27e2b0835fbd9b (patch)
tree6a009863d155a3ccdf53f193480f20ac3d2358c5 /tests/java5/annotations
parentd293b89939ff681054b47aa48ce6942bb9fcb2b4 (diff)
downloadaspectj-592467e8a30dac18931ffed58a27e2b0835fbd9b.tar.gz
aspectj-592467e8a30dac18931ffed58a27e2b0835fbd9b.zip
annotation tests for this and target
Diffstat (limited to 'tests/java5/annotations')
-rw-r--r--tests/java5/annotations/thisOrtarget/TestingAnnotations.jarbin0 -> 3061 bytes
-rw-r--r--tests/java5/annotations/thisOrtarget/TestingAnnotations.java51
-rw-r--r--tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj50
3 files changed, 101 insertions, 0 deletions
diff --git a/tests/java5/annotations/thisOrtarget/TestingAnnotations.jar b/tests/java5/annotations/thisOrtarget/TestingAnnotations.jar
new file mode 100644
index 000000000..d5dbd0b5e
--- /dev/null
+++ b/tests/java5/annotations/thisOrtarget/TestingAnnotations.jar
Binary files differ
diff --git a/tests/java5/annotations/thisOrtarget/TestingAnnotations.java b/tests/java5/annotations/thisOrtarget/TestingAnnotations.java
new file mode 100644
index 000000000..67ad612a6
--- /dev/null
+++ b/tests/java5/annotations/thisOrtarget/TestingAnnotations.java
@@ -0,0 +1,51 @@
+public class TestingAnnotations {
+
+ public static void main(String[] args) {
+
+ A a = new A();
+ B b = new B();
+ C c = new C();
+ D d = new D();
+ A reallyB = new B();
+ C reallyD = new D();
+
+ a.doSomething();
+ b.doSomething();
+ c.doSomething();
+ d.doSomething();
+ reallyB.doSomething();
+ reallyD.doSomething();
+ }
+
+}
+
+@MyClassRetentionAnnotation
+class A {
+ public void doSomething() {}
+}
+
+
+@MyAnnotation
+class B extends A {
+ public void doSomething() {}
+}
+
+@MyInheritableAnnotation
+@MyAnnotation
+class C {
+ public void doSomething() {}
+}
+
+class D extends C {
+ public void doSomething() {}
+}
+
+
+@interface MyClassRetentionAnnotation {}
+
+@java.lang.annotation.Retention(value=java.lang.annotation.RetentionPolicy.RUNTIME)
+@interface MyAnnotation {}
+
+@java.lang.annotation.Retention(value=java.lang.annotation.RetentionPolicy.RUNTIME)
+@java.lang.annotation.Inherited
+@interface MyInheritableAnnotation {} \ No newline at end of file
diff --git a/tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj b/tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj
new file mode 100644
index 000000000..c642da9aa
--- /dev/null
+++ b/tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj
@@ -0,0 +1,50 @@
+import java.util.List;
+
+public aspect ThisOrTargetTests {
+
+ pointcut doSomethingExecution() : execution(* doSomething());
+ pointcut doSomethingCall() : call(* doSomething());
+
+ before() : doSomethingExecution() && @this(@MyAnnotation) {
+ // should match:
+ // b.doSomething(), reallyB.doSomething() [with test],
+ // c.doSomething()
+ System.out.println("@this(@MyAnnotation): " + thisJoinPointStaticPart);
+ }
+
+ before() : doSomethingExecution() && @this(@MyClassRetentionAnnotation) {
+ // should be compile-time error!
+ }
+
+ before() : doSomethingExecution() && @this(@MyInheritableAnnotation) {
+ // should match:
+ // c.doSomething()
+ // d.doSomething()
+ // reallyD.doSomething()
+ System.out.println("@this(@MyInheritableAnnotation): " + thisJoinPointStaticPart);
+ }
+
+ after() returning : doSomthingCall() && @target(@MyAnnotation) {
+ // should match:
+ // b.doSomething(), reallyB.doSomething() [with test],
+ // c.doSomething()
+ System.out.println("@target(@MyAnnotation): " + thisJoinPointStaticPart);
+ }
+
+ after() returning : doSomethingCall() && @target(@MyClassRetentionAnnotation) {
+ // should be compile-time error!
+ }
+
+ after() returning : doSomethingCall() && @target(@MyInheritableAnnotation) {
+ // should match:
+ // c.doSomething()
+ // d.doSomething()
+ // reallyD.doSomething()
+ System.out.println("@target(@MyInheritableAnnotation): " + thisJoinPointStaticPart);
+ }
+
+ after(MyAnnotation ann) returning : @target(ann) {
+ // should be compile time error (limitation)
+ }
+
+} \ No newline at end of file