blob: 10553e90a0a7cd649fe4ea5d3c161410f1040621 (
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
|
// inner aspects and around
import org.aspectj.testing.Tester;
public class Driver {
public static void test() {
C2 c2 = new C2();
Tester.checkEqual(c2.foo(), 142, "modified c2.foo()");
}
public static void main(String[] args) { test(); }
}
class C1 {
private int myInteger = 100;
static aspect A {
int around(C2 c2):
target(c2) && call(int foo()) {
int result = proceed(c2);
return result + c2.getC1().myInteger;
}
}
}
class C2 {
public C1 getC1() {
return new C1();
}
int foo() {
return 42;
}
}
|