blob: 84ddaea56e5e4e205083f6348fe4b71a9ddb6ff0 (
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
35
36
37
38
39
40
|
import org.aspectj.testing.Tester;
// PR#114, PR#115
public class OrderOfCatches {
public static void main(String[] args) { test(); }
public static void test() {
A a = new A();
try {
a.bar();
Tester.check( true, "" );
}
catch ( FooException fe ) {
}
Tester.checkEqual(a.s, "a-FooException-EXC:FooException", "");
}
}
class A {
public String s = "a";
void bar() throws FooException {
foo();
}
void foo() throws FooException {
throw new FooException();
}
}
aspect AA {
pointcut m(A a): target(a) && call(void bar());
after (A a) throwing (FooException e): m(a) {
a.s += "-" + e.getClass().getName();
}
after (A a) throwing (Exception e): m(a) {
a.s += "-" + "EXC:"+e.getClass().getName();
}
}
class FooException extends Exception {}
|