diff options
Diffstat (limited to 'tests/decs/DeclareSoftRuntimeException.aj')
-rw-r--r-- | tests/decs/DeclareSoftRuntimeException.aj | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/decs/DeclareSoftRuntimeException.aj b/tests/decs/DeclareSoftRuntimeException.aj new file mode 100644 index 000000000..379ba645c --- /dev/null +++ b/tests/decs/DeclareSoftRuntimeException.aj @@ -0,0 +1,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 {} |