Parcourir la source

329925: declare @field remove annotation

tags/V1_6_11M1
aclement il y a 13 ans
Parent
révision
8a0954f7a2

+ 4
- 0
tests/features1611/declareMinus/AnnotationA.java Voir le fichier

@@ -0,0 +1,4 @@
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@interface AnnotationA {}

+ 4
- 0
tests/features1611/declareMinus/AnnotationB.java Voir le fichier

@@ -0,0 +1,4 @@
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@interface AnnotationB {}

+ 20
- 0
tests/features1611/declareMinus/Code.java Voir le fichier

@@ -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");
}
}


+ 20
- 0
tests/features1611/declareMinus/Code2.java Voir le fichier

@@ -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");
}
}


+ 26
- 0
tests/features1611/declareMinus/Code3.java Voir le fichier

@@ -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");
}
}


+ 30
- 0
tests/features1611/declareMinus/OnOff.java Voir le fichier

@@ -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"));
}
}


+ 25
- 0
tests/features1611/declareMinus/OnOff2.java Voir le fichier

@@ -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"));
}
}


+ 10
- 0
tests/features1611/declareMinus/aspectjtest/AnnotationA.java Voir le fichier

@@ -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 {}

+ 10
- 0
tests/features1611/declareMinus/aspectjtest/AnnotationB.java Voir le fichier

@@ -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 {}

+ 9
- 0
tests/features1611/declareMinus/aspectjtest/ExampleItd.aj Voir le fichier

@@ -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;
}

+ 10
- 0
tests/features1611/declareMinus/aspectjtest/HelloTest.java Voir le fichier

@@ -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());
}
}

+ 6
- 0
tests/features1611/declareMinus/aspectjtest/MyEntity.java Voir le fichier

@@ -0,0 +1,6 @@
package aspectjtest;

public class MyEntity {

@AnnotationA private String myField;
}

Chargement…
Annuler
Enregistrer