From 592467e8a30dac18931ffed58a27e2b0835fbd9b Mon Sep 17 00:00:00 2001 From: acolyer Date: Thu, 9 Dec 2004 14:02:47 +0000 Subject: [PATCH] annotation tests for this and target --- .../thisOrtarget/TestingAnnotations.jar | Bin 0 -> 3061 bytes .../thisOrtarget/TestingAnnotations.java | 51 ++++++++++++++++++ .../thisOrtarget/ThisOrTargetTests.aj | 50 +++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 tests/java5/annotations/thisOrtarget/TestingAnnotations.jar create mode 100644 tests/java5/annotations/thisOrtarget/TestingAnnotations.java create mode 100644 tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj diff --git a/tests/java5/annotations/thisOrtarget/TestingAnnotations.jar b/tests/java5/annotations/thisOrtarget/TestingAnnotations.jar new file mode 100644 index 0000000000000000000000000000000000000000..d5dbd0b5e3d7da8468f2b71e24b7e3bf2bac0815 GIT binary patch literal 3061 zcmai02UJtp77YPHDAIy}6e08?K@kQK1Vae~3<(%O>PYX2^w`D;QdN{92!cvg5e6yJ z2?K~A7^*0sD3LDuN4ilX&I_L}nBb9WXiJp(Y9|Q93c^`%K$#=J>%(wA1PcKpzJoDHOEk*lC?0`9En=uoj##K6 z`gT~TsdQ6&Dy;Vo?59lzBg`>-(3rlkdu*KPv%6-5X>QdP$u2XZYOF6m2@+v;ZSLbwNSr_L&HL{+F zCR|ckk(Dr>;TO}k4XBaF_jKQaRwg-WhRL>hA8B8`=H~s#pE-oQ;^#-7 z4^k-_I;eM3)58_*l@OH|4F`9^ zcRE!fj&$hzBEnloxH}SP?zMtWbkJF)AVFhxj;YuW61*YwGv7d^O`1)hc6}KsSj*f6 zt(X2Sv@s3Y8tvQosE+HEb^b+$&t5i=1T_#CKNZi9#ZpkD--}as2(>AeRrkswVSgob zsfoX$N-a)j@sC!&2rked9J5{(h4!6VT;NWFJCWEN(256QWwGItW*5Pq@Fhow^muIGu|h|# zv3T|JTFTS@gXu5yaE)Qz9I%0UhFhS^rQ>r>HQ9wXd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/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 -- 2.39.5