From b4574b90b2db6cdae830e702825d86957447c3b9 Mon Sep 17 00:00:00 2001 From: acolyer Date: Thu, 17 Feb 2005 12:58:24 +0000 Subject: support for annotations on ITDs, and declare annotation --- .../annotations/aspectMembers/a/AnnotatedAspect.aj | 23 +++++++++++++++++ .../aspectMembers/a/AnnotatedAspect02.aj | 22 ++++++++++++++++ .../aspectMembers/a/AnnotatedAspect03.aj | 26 +++++++++++++++++++ .../aspectMembers/a/AnnotatedAspect04.aj | 15 +++++++++++ .../annotations/aspectMembers/a/Annotations.java | 29 ++++++++++++++++++++++ tests/java5/annotations/aspectMembers/a/Foo.java | 17 +++++++++++++ 6 files changed, 132 insertions(+) create mode 100644 tests/java5/annotations/aspectMembers/a/AnnotatedAspect.aj create mode 100644 tests/java5/annotations/aspectMembers/a/AnnotatedAspect02.aj create mode 100644 tests/java5/annotations/aspectMembers/a/AnnotatedAspect03.aj create mode 100644 tests/java5/annotations/aspectMembers/a/AnnotatedAspect04.aj create mode 100644 tests/java5/annotations/aspectMembers/a/Annotations.java create mode 100644 tests/java5/annotations/aspectMembers/a/Foo.java (limited to 'tests/java5/annotations/aspectMembers') diff --git a/tests/java5/annotations/aspectMembers/a/AnnotatedAspect.aj b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect.aj new file mode 100644 index 000000000..03165b105 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect.aj @@ -0,0 +1,23 @@ +package a; + +@TypeAnnotation +public aspect AnnotatedAspect { + + @FieldAnnotation int foo = 5; + + @MethodAnnotation int getFoo() { return foo; } + + @ConstructorAnnotation + public AnnotatedAspect() {} + +} + +aspect VerifyAnnotations { + + declare warning : set(@FieldAnnotation * *) : "annotated field"; + declare warning : execution(@MethodAnnotation * *(..)) : "annotated method"; + declare warning : execution(@ConstructorAnnotation new(..)) : "annotated constructor"; + declare warning : staticinitialization(@TypeAnnotation *) : "annotated type"; + + +} \ No newline at end of file diff --git a/tests/java5/annotations/aspectMembers/a/AnnotatedAspect02.aj b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect02.aj new file mode 100644 index 000000000..d92dc33b1 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect02.aj @@ -0,0 +1,22 @@ +package a; + +@MethodAnnotation +public aspect AnnotatedAspect02 { + + @TypeAnnotation int goo; + + @FieldAnnotation int getGoo() { return goo; } + + @AnnotationAnnotation AnnotatedAspect02() { goo = 5; } + +} + +aspect VerifyAnnotations { + + declare warning : set(@FieldAnnotation * *) : "annotated field"; + declare warning : execution(@MethodAnnotation * *(..)) : "annotated method"; + declare warning : execution(@ConstructorAnnotation new(..)) : "annotated constructor"; + declare warning : staticinitialization(@TypeAnnotation *) : "annotated type"; + + +} \ No newline at end of file diff --git a/tests/java5/annotations/aspectMembers/a/AnnotatedAspect03.aj b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect03.aj new file mode 100644 index 000000000..939285816 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect03.aj @@ -0,0 +1,26 @@ +package a; + +@TypeAnnotation +public aspect AnnotatedAspect03 { + + @FieldAnnotation int foo = 5; + + @FieldAnnotation private int ITDMe.goo = 3; + + @MethodAnnotation private int ITDMe.getGoo() { return goo; } + + @ConstructorAnnotation public ITDMe.new(int x) { goo = x; } + +} + +class ITDMe {} + +aspect VerifyAnnotations { + + declare warning : set(@FieldAnnotation * *) : "annotated field"; + declare warning : execution(@MethodAnnotation * *(..)) : "annotated method"; + declare warning : execution(@ConstructorAnnotation new(..)) : "annotated constructor"; + declare warning : staticinitialization(@TypeAnnotation *) : "annotated type"; + + +} \ No newline at end of file diff --git a/tests/java5/annotations/aspectMembers/a/AnnotatedAspect04.aj b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect04.aj new file mode 100644 index 000000000..c19b057a3 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/AnnotatedAspect04.aj @@ -0,0 +1,15 @@ +package a; + +@TypeAnnotation +public aspect AnnotatedAspect04 { + + @ConstructorAnnotation private int ITDMe.goo = 3; + + @FieldAnnotation private int ITDMe.getGoo() { return goo; } + + @TypeAnnotation public ITDMe.new(int x) { goo = x; } + + @MethodAnnotation int ITDMe.foo = 2; // known limitation - no warning +} + +class ITDMe {} diff --git a/tests/java5/annotations/aspectMembers/a/Annotations.java b/tests/java5/annotations/aspectMembers/a/Annotations.java new file mode 100644 index 000000000..21a0bb1a7 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/Annotations.java @@ -0,0 +1,29 @@ +package a; + +import java.lang.annotation.*; + +@Target(ElementType.ANNOTATION_TYPE) +@interface AnnotationAnnotation {} + +@Target(ElementType.CONSTRUCTOR) +@interface ConstructorAnnotation {} + +@Target(ElementType.FIELD) +@interface FieldAnnotation {} + +@Target(ElementType.LOCAL_VARIABLE) +@interface LocalVarAnnotation {} + +@Target(ElementType.METHOD) +@interface MethodAnnotation {} + +@Target(ElementType.PACKAGE) +@interface PackageAnnotation {} + +@Target(ElementType.PARAMETER) +@interface ParameterAnnotation {} + +@Target(ElementType.TYPE) +@interface TypeAnnotation {} + +@interface AnyAnnotation {} \ No newline at end of file diff --git a/tests/java5/annotations/aspectMembers/a/Foo.java b/tests/java5/annotations/aspectMembers/a/Foo.java new file mode 100644 index 000000000..3fd621e26 --- /dev/null +++ b/tests/java5/annotations/aspectMembers/a/Foo.java @@ -0,0 +1,17 @@ +package a; + +/** + * @author colyer + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +@TypeAnnotation +public class Foo { + + @FieldAnnotation int foo; + + @MethodAnnotation int getFoo() { return foo; } + + @MethodAnnotation int goo; +} -- cgit v1.2.3