blob: d96984c72463bf3d1ec63dccd8e9989c79eeac16 (
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
|
import java.lang.annotation.*;
import java.lang.reflect.*;
@Retention(RetentionPolicy.RUNTIME)
@interface Ann {}
aspect X {
@Ann public void AtItd2.m() {}
}
public class AtItd2 {
public static void main(String []argv) {
try {
Method m = AtItd2.class.getDeclaredMethod("m",null);
System.err.println("Method is "+m);
Annotation[] as = m.getDeclaredAnnotations();
System.err.println("Number of annotations "+
(as==null?"0":new Integer(as.length).toString()));
Annotation aa = m.getAnnotation(Ann.class);
System.err.println("Ann.class retrieved is: "+aa);
if (as.length==0)
throw new RuntimeException("Couldn't find annotation on member!");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}
|