From: aclement Date: Wed, 24 Nov 2010 18:35:20 +0000 (+0000) Subject: 329925: declare @field remove annotation X-Git-Tag: V1_6_11M1~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8a0954f7a241ece8c339709b97cec2cb889e108a;p=aspectj.git 329925: declare @field remove annotation --- diff --git a/tests/features1611/declareMinus/AnnotationA.java b/tests/features1611/declareMinus/AnnotationA.java new file mode 100644 index 000000000..e7f1fbafc --- /dev/null +++ b/tests/features1611/declareMinus/AnnotationA.java @@ -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 index 000000000..be6d5d4d3 --- /dev/null +++ b/tests/features1611/declareMinus/AnnotationB.java @@ -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 index 000000000..133c60249 --- /dev/null +++ b/tests/features1611/declareMinus/Code.java @@ -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 index 000000000..4c26cd196 --- /dev/null +++ b/tests/features1611/declareMinus/Code2.java @@ -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 index 000000000..b4800e0db --- /dev/null +++ b/tests/features1611/declareMinus/Code3.java @@ -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 index 000000000..479359b35 --- /dev/null +++ b/tests/features1611/declareMinus/OnOff.java @@ -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 index 000000000..c9c888bbf --- /dev/null +++ b/tests/features1611/declareMinus/OnOff2.java @@ -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 index 000000000..29c50da80 --- /dev/null +++ b/tests/features1611/declareMinus/aspectjtest/AnnotationA.java @@ -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 index 000000000..007386a94 --- /dev/null +++ b/tests/features1611/declareMinus/aspectjtest/AnnotationB.java @@ -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 index 000000000..7f7521cf3 --- /dev/null +++ b/tests/features1611/declareMinus/aspectjtest/ExampleItd.aj @@ -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 index 000000000..a6eb3678e --- /dev/null +++ b/tests/features1611/declareMinus/aspectjtest/HelloTest.java @@ -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 index 000000000..a5d4731c2 --- /dev/null +++ b/tests/features1611/declareMinus/aspectjtest/MyEntity.java @@ -0,0 +1,6 @@ +package aspectjtest; + +public class MyEntity { + + @AnnotationA private String myField; +}