mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-08-14 14:11:27 +02:00
42 lines
1013 B
Plaintext
42 lines
1013 B
Plaintext
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 {}
|