From eabf8a19cab6071dedbdcf86747123126349f401 Mon Sep 17 00:00:00 2001 From: acolyer Date: Fri, 10 Dec 2004 13:21:26 +0000 Subject: @within, @withincode tests --- .../java5/annotations/thisOrtarget/DeclareEoW.java | 7 +++ .../annotations/within_code/TestingAnnotations.jar | Bin 0 -> 3486 bytes .../within_code/TestingAnnotations.java | 54 +++++++++++++++++++++ .../within_code/WithinAndWithinCodeTests.java | 14 ++++++ 4 files changed, 75 insertions(+) create mode 100644 tests/java5/annotations/thisOrtarget/DeclareEoW.java create mode 100644 tests/java5/annotations/within_code/TestingAnnotations.jar create mode 100644 tests/java5/annotations/within_code/TestingAnnotations.java create mode 100644 tests/java5/annotations/within_code/WithinAndWithinCodeTests.java (limited to 'tests/java5/annotations') diff --git a/tests/java5/annotations/thisOrtarget/DeclareEoW.java b/tests/java5/annotations/thisOrtarget/DeclareEoW.java new file mode 100644 index 000000000..491e5400d --- /dev/null +++ b/tests/java5/annotations/thisOrtarget/DeclareEoW.java @@ -0,0 +1,7 @@ +public aspect DeclareEoW { + + declare warning : @this(@MyAnnotation) : "should give compilation error"; + + declare error : @target(@MyAnnotation) : "should give compilation error"; + +} \ No newline at end of file diff --git a/tests/java5/annotations/within_code/TestingAnnotations.jar b/tests/java5/annotations/within_code/TestingAnnotations.jar new file mode 100644 index 000000000..769d7ec71 Binary files /dev/null and b/tests/java5/annotations/within_code/TestingAnnotations.jar differ diff --git a/tests/java5/annotations/within_code/TestingAnnotations.java b/tests/java5/annotations/within_code/TestingAnnotations.java new file mode 100644 index 000000000..35eb49e12 --- /dev/null +++ b/tests/java5/annotations/within_code/TestingAnnotations.java @@ -0,0 +1,54 @@ +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 { + + @MyClassRetentionAnnotation public void doSomething(C c) { + c.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/within_code/WithinAndWithinCodeTests.java b/tests/java5/annotations/within_code/WithinAndWithinCodeTests.java new file mode 100644 index 000000000..96ed0188d --- /dev/null +++ b/tests/java5/annotations/within_code/WithinAndWithinCodeTests.java @@ -0,0 +1,14 @@ +public aspect WithinAndWithinCodeTests { + + // should be two matches, L32 and L39 + declare warning : execution(* doSomething(..)) && @within(@MyAnnotation) + : "@within match on non-inherited annotation"; + + // one match on L39 + declare warning : execution(* doSomething(..)) && @within(@MyInheritableAnnotation) + : "@within match on inheritable annotation"; + + // one match on L32 + declare warning : call(* doSomething(..)) && @withincode(@MyClassRetentionAnnotation) + : "@withincode match"; +} \ No newline at end of file -- cgit v1.2.3