mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-08-14 02:10:40 +02:00
29 lines
667 B
Java
29 lines
667 B
Java
import org.aspectj.testing.Tester;
|
|
|
|
public class ComputedThrows {
|
|
public static void main(String[] args) { test(); }
|
|
public static void test() {
|
|
new ComputedThrows().bar();
|
|
Tester.check("ran bar");
|
|
Tester.check("caught Exception");
|
|
}
|
|
void bar() throws Exception {
|
|
Tester.note("ran bar");
|
|
throw new Exception();
|
|
}
|
|
}
|
|
|
|
aspect Aspect {
|
|
pointcut Foo(): within(ComputedThrows) && call(* ComputedThrows.bar(..));
|
|
|
|
declare soft: Exception: Foo();
|
|
|
|
void around(): Foo() {
|
|
try {
|
|
proceed();
|
|
} catch (Exception e) {
|
|
Tester.note("caught Exception");
|
|
}
|
|
}
|
|
}
|