blob: 7e04aed7644f3afb3586d9edc6608857412db774 (
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
|
package p.q;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME) @interface Colored {String value();}
@Retention(RetentionPolicy.RUNTIME) @interface Fruit {String value();}
@Retention(RetentionPolicy.RUNTIME) @interface Material {String value();}
aspect AllTogether {
declare @type: DeathByAnnotations: @Colored("red");
declare @method: * m*(..): @Fruit("tomato");
declare @constructor: DeathByAnnotations.new(..): @Fruit("tomato");
declare @field: * DeathByAnnotations.*: @Material("wood");
}
public class DeathByAnnotations {
int i;
static String s;
public static void main(String[]argv) {
new DeathByAnnotations().i = 3;
s = "hello";
new DeathByAnnotations().m1();
new DeathByAnnotations(3).m2();
}
public DeathByAnnotations() {}
public DeathByAnnotations(int i) {}
public void m1() {}
public void m2() {}
}
|