]> source.dussan.org Git - aspectj.git/commitdiff
329925: declare @field remove annotation
authoraclement <aclement>
Wed, 24 Nov 2010 18:35:20 +0000 (18:35 +0000)
committeraclement <aclement>
Wed, 24 Nov 2010 18:35:20 +0000 (18:35 +0000)
12 files changed:
tests/features1611/declareMinus/AnnotationA.java [new file with mode: 0644]
tests/features1611/declareMinus/AnnotationB.java [new file with mode: 0644]
tests/features1611/declareMinus/Code.java [new file with mode: 0644]
tests/features1611/declareMinus/Code2.java [new file with mode: 0644]
tests/features1611/declareMinus/Code3.java [new file with mode: 0644]
tests/features1611/declareMinus/OnOff.java [new file with mode: 0644]
tests/features1611/declareMinus/OnOff2.java [new file with mode: 0644]
tests/features1611/declareMinus/aspectjtest/AnnotationA.java [new file with mode: 0644]
tests/features1611/declareMinus/aspectjtest/AnnotationB.java [new file with mode: 0644]
tests/features1611/declareMinus/aspectjtest/ExampleItd.aj [new file with mode: 0644]
tests/features1611/declareMinus/aspectjtest/HelloTest.java [new file with mode: 0644]
tests/features1611/declareMinus/aspectjtest/MyEntity.java [new file with mode: 0644]

diff --git a/tests/features1611/declareMinus/AnnotationA.java b/tests/features1611/declareMinus/AnnotationA.java
new file mode 100644 (file)
index 0000000..e7f1fba
--- /dev/null
@@ -0,0 +1,4 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationA {}
diff --git a/tests/features1611/declareMinus/AnnotationB.java b/tests/features1611/declareMinus/AnnotationB.java
new file mode 100644 (file)
index 0000000..be6d5d4
--- /dev/null
@@ -0,0 +1,4 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationB {}
diff --git a/tests/features1611/declareMinus/Code.java b/tests/features1611/declareMinus/Code.java
new file mode 100644 (file)
index 0000000..133c602
--- /dev/null
@@ -0,0 +1,20 @@
+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");
+  }
+}
+
diff --git a/tests/features1611/declareMinus/Code2.java b/tests/features1611/declareMinus/Code2.java
new file mode 100644 (file)
index 0000000..4c26cd1
--- /dev/null
@@ -0,0 +1,20 @@
+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");
+  }
+}
+
diff --git a/tests/features1611/declareMinus/Code3.java b/tests/features1611/declareMinus/Code3.java
new file mode 100644 (file)
index 0000000..b4800e0
--- /dev/null
@@ -0,0 +1,26 @@
+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");
+  }
+}
+
diff --git a/tests/features1611/declareMinus/OnOff.java b/tests/features1611/declareMinus/OnOff.java
new file mode 100644 (file)
index 0000000..479359b
--- /dev/null
@@ -0,0 +1,30 @@
+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"));
+  }
+}
+
diff --git a/tests/features1611/declareMinus/OnOff2.java b/tests/features1611/declareMinus/OnOff2.java
new file mode 100644 (file)
index 0000000..c9c888b
--- /dev/null
@@ -0,0 +1,25 @@
+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"));
+  }
+}
+
diff --git a/tests/features1611/declareMinus/aspectjtest/AnnotationA.java b/tests/features1611/declareMinus/aspectjtest/AnnotationA.java
new file mode 100644 (file)
index 0000000..29c50da
--- /dev/null
@@ -0,0 +1,10 @@
+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 {}
diff --git a/tests/features1611/declareMinus/aspectjtest/AnnotationB.java b/tests/features1611/declareMinus/aspectjtest/AnnotationB.java
new file mode 100644 (file)
index 0000000..007386a
--- /dev/null
@@ -0,0 +1,10 @@
+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 {}
diff --git a/tests/features1611/declareMinus/aspectjtest/ExampleItd.aj b/tests/features1611/declareMinus/aspectjtest/ExampleItd.aj
new file mode 100644 (file)
index 0000000..7f7521c
--- /dev/null
@@ -0,0 +1,9 @@
+// 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;
+}
diff --git a/tests/features1611/declareMinus/aspectjtest/HelloTest.java b/tests/features1611/declareMinus/aspectjtest/HelloTest.java
new file mode 100644 (file)
index 0000000..a6eb367
--- /dev/null
@@ -0,0 +1,10 @@
+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());
+       }
+}
diff --git a/tests/features1611/declareMinus/aspectjtest/MyEntity.java b/tests/features1611/declareMinus/aspectjtest/MyEntity.java
new file mode 100644 (file)
index 0000000..a5d4731
--- /dev/null
@@ -0,0 +1,6 @@
+package aspectjtest;
+
+public class MyEntity {
+
+       @AnnotationA private String myField;
+}