String foo();
}
+@Retention(RetentionPolicy.RUNTIME)
+@interface Banno {
+ String hoo() default "abcde";
+}
+
+
@Anno(foo="anc")
aspect X {
declare @method: int i(..): -@Anno;
declare @type: X: -@Anno;
declare @field: int i: -@Anno(foo="abc");
+
public static void main(String[] args) throws Exception {
if (X.class.getDeclaredField("i").getAnnotation(Anno.class)==null) {
} else {
System.out.println("failed");
}
+ if (X.class.getDeclaredField("j").getAnnotation(Banno.class)==null) {
+ System.out.println("not on j");
+ } else {
+ System.out.println("is on j");
+ }
}
+
+ int j;
}
\ No newline at end of file
-import java.lang.annotation.Retention;
+import java.lang.annotation.*;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
int i;
declare @field: int i: -@Anno;
+ declare @field: int j: @Banno(hoo="abc");
+ int j;
public static void main(String[] args) throws Exception {
if (WithValues.class.getDeclaredField("i").getAnnotation(Anno.class)==null) {
- System.out.println("not there");
+ System.out.println("i does not have Anno");
} else {
- System.out.println("failed");
+ System.out.println("i has Anno");
+ }
+ Annotation a = WithValues.class.getDeclaredField("j").getAnnotation(Banno.class);
+ if (a==null) {
+ System.out.println("j does not have Banno");
+ } else {
+ System.out.println("j has Banno:"+a);
+ }
+ a = WithValues.class.getDeclaredField("j").getAnnotation(Anno.class);
+ if (a==null) {
+ System.out.println("j does not have Anno");
+ } else {
+ System.out.println("j has Anno:"+a);
}
}
-}
\ No newline at end of file
+}
+@Retention(RetentionPolicy.RUNTIME)
+@interface Banno {
+ String hoo();
+}
<compile files="WithValues.java" options="-1.5"/>
<run class="WithValues">
<stdout>
- <line text="not there"/>
+ <line text="i does not have Anno"/>
+ <line text="j has Banno:@Banno(hoo=abc)"/>
+ <line text="j does not have Anno"/>
</stdout></run>
</ajc-test>
<ajc-test dir="features1611/declareMinus" title="declare minus - unsupported">
<compile files="Unsupported.java" options="-1.5">
- <message kind="error" line="13" text="Annotation removal only supported for declare @field (compiler limitation)"/>
- <message kind="error" line="14" text="Annotation removal only supported for declare @field (compiler limitation)"/>
- <message kind="error" line="15" text="Annotation removal does not allow values to be specified for the annotation (compiler limitation)"/>
+ <message kind="error" line="19" text="Annotation removal only supported for declare @field (compiler limitation)"/>
+ <message kind="error" line="20" text="Annotation removal only supported for declare @field (compiler limitation)"/>
+ <message kind="error" line="21" text="Annotation removal does not allow values to be specified for the annotation (compiler limitation)"/>
</compile>
</ajc-test>