12345678910111213141516171819202122232425262728293031323334353637 |
- public class MultiCatchWithHandler {
-
- public static void main(String[] args) {
- try {
- foo("abc");
- } catch (ExceptionA | ExceptionB ex) {
- bar(ex);
- }
- }
-
- public static void bar(Exception ea) {
-
- }
-
- public static void foo(String s) throws ExceptionA, ExceptionB {
- if (s.equals("ta")) {
- throw new ExceptionA();
- } else {
- throw new ExceptionB();
- }
- }
- }
-
- @SuppressWarnings("serial")
- class ExceptionA extends Exception {
- }
-
- @SuppressWarnings("serial")
- class ExceptionB extends Exception {
- }
-
-
- aspect X {
- before(ExceptionA ea): handler(ExceptionA) && args(ea) {
- System.out.println("in advice");
- }
- }
|