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.

12345678910111213141516171819202122232425262728
  1. import org.aspectj.testing.Tester;
  2. public class ComputedThrows {
  3. public static void main(String[] args) { test(); }
  4. public static void test() {
  5. new ComputedThrows().bar();
  6. Tester.check("ran bar");
  7. Tester.check("caught Exception");
  8. }
  9. void bar() throws Exception {
  10. Tester.note("ran bar");
  11. throw new Exception();
  12. }
  13. }
  14. aspect Aspect {
  15. pointcut Foo(): within(ComputedThrows) && call(* ComputedThrows.bar(..));
  16. declare soft: Exception: Foo();
  17. void around(): Foo() {
  18. try {
  19. proceed();
  20. } catch (Exception e) {
  21. Tester.note("caught Exception");
  22. }
  23. }
  24. }