You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233
  1. import org.aspectj.testing.Tester;
  2. public class TryErrors {
  3. public static void main(String[] args) {
  4. test();
  5. }
  6. public static void test() {
  7. Foo foo = new Foo();
  8. foo.bar();
  9. Tester.check(foo.memberAdvised, "member advice happened");
  10. Tester.check(foo.signatureAdvised, "signature advice happened");
  11. }
  12. }
  13. class Foo {
  14. boolean memberAdvised = false;
  15. boolean signatureAdvised = false;
  16. public void bar() {
  17. ;
  18. }
  19. }
  20. aspect A {
  21. /*static*/ after(Foo foo): target(foo) && within(Foo) && execution(void bar()) {
  22. foo.memberAdvised = true;
  23. }
  24. /*static*/ before(Foo foo): target(foo) && call(void bar()) {
  25. foo.signatureAdvised = true;
  26. }
  27. }