blob: f39609643e1a6755d98ded4b22b7c6aecd14e26b (
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
|
import java.lang.annotation.*;
import org.aspectj.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@interface SomeAnnotation {}
@SomeAnnotation
public class CaseA {
public static void main(String[]argv) {
CaseA ca = new CaseA();
((I)ca).methodOne(); // will only succeed if mixin applied
}
}
@SomeAnnotation
enum Color {R,G,B}
aspect X {
@DeclareMixin("(@SomeAnnotation *)")
public static I createImplementation() {
System.out.println("Delegate factory invoked");
return new Implementation();
}
}
interface I {
void methodOne();
}
class Implementation implements I {
public void methodOne() {
System.out.println("methodOne running");
}
}
|