blob: 379ba645c16a0387c2822360dce3d45b402c85f6 (
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
41
|
public aspect DeclareSoftRuntimeException {
declare soft : MyRuntimeException : execution(* *(..));
declare soft : MyException : execution(* *(..));
declare soft : Exception : execution(void throwMyExceptionButNotReally());
public static void main(String[] args) {
try {
throwMyRuntimeException();
} catch(Exception ex) {
System.out.println(ex.getClass().getName());
}
try {
throwMyException();
} catch(Exception ex) {
System.out.println(ex.getClass().getName());
}
try {
throwMyExceptionButNotReally();
} catch(Exception ex) {
System.out.println(ex.getClass().getName());
}
}
private static void throwMyRuntimeException() {
throw new MyRuntimeException();
}
private static void throwMyException() throws MyException {
throw new MyException();
}
private static void throwMyExceptionButNotReally() throws MyException {
throw new MyRuntimeException();
}
}
class MyRuntimeException extends RuntimeException {}
class MyException extends Exception {}
|