blob: 4f36edcfb67fe81d90f1c056aa9438ad0f5e6a8f (
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
39
40
41
42
43
44
|
// Annotated ITD (method) being matched upon and extracted
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
public aspect BindingWithDeclaredAnnotationItds1 {
int A.m() { return 1; }
public int A.n() { return 2; }
private int A.o() { return 3; }
public static void main(String[]argv) {
A a = new A();
a.m();
a.n();
a.o();
}
}
class A { }
aspect X {
declare @method: int A.m(): @Fruit("orange");
declare @method: int A.n(): @Fruit("banana");
declare @method: int A.o(): @Fruit("tomato");
before(Fruit f): execution(* *(..)) && @annotation(f) {
System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
" ("+thisJoinPoint.getSourceLocation()+")");
}
before(Fruit f): call(* *(..)) && @annotation(f) {
System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
" ("+thisJoinPoint.getSourceLocation()+")");
}
}
|