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.

Code.java 560B

123456789101112131415161718192021222324252627282930
  1. package mypackage;
  2. aspect Azpect {
  3. pointcut pc(Object o) : this(o) && execution(* (Code).n*(..));
  4. after(Object o) throwing(Exception e) : pc(o) {
  5. System.out.println("caught it");
  6. // e.printStackTrace();
  7. }
  8. }
  9. public class Code {
  10. // anotherCaughtMethod is NOT advised -- <<< ERROR <<< this should be advised
  11. public void n() { throw new RuntimeException("n"); }
  12. public static void main(String[]argv) {
  13. try {
  14. new Code().n();
  15. } catch (Exception e) {
  16. }
  17. System.out.println("done");
  18. }
  19. }