mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-09-03 05:54:57 +02:00
37 lines
636 B
Java
37 lines
636 B
Java
// 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;
|
|
}
|
|
}
|
|
|