--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationA {}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationB {}
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {}
+
+aspect Foo {
+ declare @field: * Code.someField: -@Anno;
+}
+
+public class Code {
+
+ @Anno
+ public static int someField;
+
+ public static void main(String[]argv) throws Exception {
+ Object o = Code.class.getDeclaredField("someField").getAnnotation(Anno.class);
+ System.out.println(o==null?"no annotation":"has annotation");
+ }
+}
+
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {}
+
+aspect Foo {
+ declare @field: * Code2.someField: -@Anno;
+
+ @Anno
+ public int Code2.someField;
+}
+
+public class Code2 {
+
+ public static void main(String[]argv) throws Exception {
+ Object o = Code2.class.getDeclaredField("someField").getAnnotation(Anno.class);
+ System.out.println(o==null?"no annotation":"has annotation");
+ }
+}
+
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnoB {}
+
+aspect Foo {
+ declare @field: * Code3.someField: @AnnoB;
+ declare @field: * Code3.someField: -@Anno;
+}
+
+public class Code3 {
+
+ @Anno
+ public static int someField;
+
+ public static void main(String[]argv) throws Exception {
+ Object o = Code3.class.getDeclaredField("someField").getAnnotation(Anno.class);
+ System.out.println(o==null?"no Anno":"has Anno");
+ o = Code3.class.getDeclaredField("someField").getAnnotation(AnnoB.class);
+ System.out.println(o==null?"no AnnoB":"has AnnoB");
+ }
+}
+
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {}
+
+aspect Foo {
+ // one way round
+ declare @field: * OnOff.field: -@Anno;
+ declare @field: * OnOff.field: @Anno;
+
+ // the other way round
+ declare @field: * OnOff.field2: @Anno;
+ declare @field: * OnOff.field2: -@Anno;
+}
+
+public class OnOff {
+
+ public static int field;
+
+ public int field2;
+
+ public static void main(String[]argv) throws Exception {
+ Object o = OnOff.class.getDeclaredField("field").getAnnotation(Anno.class);
+ System.out.println("field annotated? "+(o==null?"no":"yes"));
+
+ o = OnOff.class.getDeclaredField("field2").getAnnotation(Anno.class);
+ System.out.println("field2 annotated? "+(o==null?"no":"yes"));
+ }
+}
+
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {}
+
+aspect Foo {
+ declare @field: @Anno * OnOff2.*: -@Anno;
+ declare @field: * OnOff2.*: @Anno;
+}
+
+public class OnOff2 {
+
+ public static int field;
+
+ public int field2;
+
+ public static void main(String[]argv) throws Exception {
+ Object o = OnOff2.class.getDeclaredField("field").getAnnotation(Anno.class);
+ System.out.println("field annotated? "+(o==null?"no":"yes"));
+
+ o = OnOff2.class.getDeclaredField("field2").getAnnotation(Anno.class);
+ System.out.println("field2 annotated? "+(o==null?"no":"yes"));
+ }
+}
+
--- /dev/null
+package aspectjtest;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(value=RetentionPolicy.RUNTIME)
+@Target(value=ElementType.FIELD)
+public @interface AnnotationA {}
--- /dev/null
+package aspectjtest;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(value=RetentionPolicy.RUNTIME)
+@Target(value=ElementType.FIELD)
+public @interface AnnotationB {}
--- /dev/null
+// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
+// You may push code into the target .java compilation unit if you wish to edit any member(s).
+
+package aspectjtest;
+
+privileged aspect ExampleItd {
+ declare @field: * MyEntity.myField: -@AnnotationA;
+ declare @field: * MyEntity.myField: @AnnotationB;
+}
--- /dev/null
+package aspectjtest;
+
+
+public class HelloTest {
+public static void main(String []argv) throws Exception {
+ System.out.println( MyEntity.class.getDeclaredField("myField").getAnnotations().length);
+// should be B
+ System.out.println(MyEntity.class.getDeclaredField("myField").getAnnotations()[0].annotationType());
+ }
+}
--- /dev/null
+package aspectjtest;
+
+public class MyEntity {
+
+ @AnnotationA private String myField;
+}