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.

OrderOfCatches.java 879B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import org.aspectj.testing.Tester;
  2. // PR#114, PR#115
  3. public class OrderOfCatches {
  4. public static void main(String[] args) { test(); }
  5. public static void test() {
  6. A a = new A();
  7. try {
  8. a.bar();
  9. Tester.check( true, "" );
  10. }
  11. catch ( FooException fe ) {
  12. }
  13. Tester.checkEqual(a.s, "a-FooException-EXC:FooException", "");
  14. }
  15. }
  16. class A {
  17. public String s = "a";
  18. void bar() throws FooException {
  19. foo();
  20. }
  21. void foo() throws FooException {
  22. throw new FooException();
  23. }
  24. }
  25. aspect AA {
  26. pointcut m(A a): target(a) && call(void bar());
  27. after (A a) throwing (FooException e): m(a) {
  28. a.s += "-" + e.getClass().getName();
  29. }
  30. after (A a) throwing (Exception e): m(a) {
  31. a.s += "-" + "EXC:"+e.getClass().getName();
  32. }
  33. }
  34. class FooException extends Exception {}