blob: 65b8d2802bd26caa2391cc611219d4eb61cea0b3 (
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
|
// Annotated ITD (ctor) being matched upon and extracted
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
public aspect BindingWithDeclaredAnnotationItds4 {
A.new(String s) { this(); }
private A.new(int i) { this(); }
public A.new(boolean b) { this(); }
public static void main(String[]argv) {
A instance1 = new A("a");
A instance2 = new A(3);
A instance3 = new A(true);
}
}
class A {
}
aspect X {
declare @constructor: A.new(String): @Fruit("pear");
declare @constructor: A.new(int): @Fruit("orange");
declare @constructor: A.new(boolean): @Fruit("tomato");
before(Fruit f): execution(new(..)) && @annotation(f) {
System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
" ("+thisJoinPoint.getSourceLocation()+")");
}
}
|