blob: 54d2af101f43a2c0b9ac3a0cb1ea9dfc827b2350 (
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
27
28
29
30
31
32
33
34
35
36
37
38
|
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@interface Anno {
String foo();
}
@Retention(RetentionPolicy.RUNTIME)
@interface Banno {
String hoo() default "abcde";
}
@Anno(foo="anc")
aspect X {
//declare @method: int i: -@Anno;
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) {
System.out.println("not there");
} 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;
}
|