blob: b4800e0db96c1c9bc22d55d4368badedccfa6a4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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");
}
}
|