blob: 93356d327dc6af39a1c66d3838a7ab86a0acd160 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package mypackage;
aspect Azpect {
pointcut pc(Object o) : this(o) && execution(* Code2.n*(..) throws Exception+);
after(Object o) throwing(Exception e) : pc(o) {
System.out.println("caught it: "+thisJoinPointStaticPart);
}
}
public class Code2 {
public void n1() { throw new RuntimeException("n"); }
public void n2() throws MyException { throw new MyException(); }
public static void main(String[]argv) {
try {
new Code2().n1();
} catch (Exception e) {}
try {
new Code2().n2();
} catch (Exception e) {}
System.out.println("done");
}
}
class MyException extends Exception {
}
|