blob: 5311d32ed63abe91e7b9e5e1692b71e887b601ef (
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
|
import org.aspectj.testing.Tester;
public class Simple {
public static void main(String[] args) {
new C().foo();
}
}
class C {
private int privateField = 1;
private int privateMethod() {
return 42;
}
public void foo() {
System.out.println("f: " + privateField);
}
}
privileged aspect A {
static before (C c): instanceof(c) && receptions(void foo()) {
System.out.println("from A: " + c.privateField);
c.privateField += 1;
System.out.println("from A: " + c.privateField);
System.out.println("from A: " + ++c.privateField);
System.out.println("from A: " + c.privateField++);
System.out.println("from A: " + c.privateField);
System.out.println("from A: " + c.privateMethod());
}
}
|