mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-08-14 02:10:40 +02:00
34 lines
719 B
Java
34 lines
719 B
Java
import org.aspectj.testing.Tester;
|
|
|
|
public class TryErrors {
|
|
public static void main(String[] args) {
|
|
test();
|
|
}
|
|
|
|
public static void test() {
|
|
Foo foo = new Foo();
|
|
foo.bar();
|
|
Tester.check(foo.memberAdvised, "member advice happened");
|
|
Tester.check(foo.signatureAdvised, "signature advice happened");
|
|
}
|
|
}
|
|
|
|
class Foo {
|
|
boolean memberAdvised = false;
|
|
boolean signatureAdvised = false;
|
|
|
|
public void bar() {
|
|
;
|
|
}
|
|
}
|
|
|
|
aspect A {
|
|
/*static*/ after(Foo foo): target(foo) && within(Foo) && execution(void bar()) {
|
|
foo.memberAdvised = true;
|
|
}
|
|
|
|
/*static*/ before(Foo foo): target(foo) && call(void bar()) {
|
|
foo.signatureAdvised = true;
|
|
}
|
|
}
|