Multi-catch support: exceptions may implement interfaces

This commit is contained in:
Roman Shevchenko
2011-02-15 18:41:03 +01:00
parent ba3304c5fe
commit b4043639ba
4 changed files with 26 additions and 10 deletions
@@ -5,14 +5,19 @@ abstract class C {
private static class E2 extends E { }
private static class E3 extends E { }
private static class RE extends RuntimeException { }
private interface I { }
private static class IE1 extends E implements I { }
private static class IE2 extends E implements I { }
abstract void f() throws E1, E2;
abstract void g() throws IE1, IE2;
void m() {
try { f(); } catch (E1 | E2 e) { }
try { f(); } catch (E2 | E e) { e.printStackTrace(); }
try { f(); } catch (E2 | E1 e) { } catch (E e) { } catch (RE e) { }
try { f(); } catch (E1 | E e) { E ee = e; }
try { g(); } catch (IE1 | IE2 e) { E ee = e; I ii = e; }
try { f(); } catch (E1 | E2 | <error descr="Exception 'C.E3' is never thrown in the corresponding try block">E3</error> e) { }
try { f(); } catch (<error descr="Exception 'C.E3' is never thrown in the corresponding try block">E3</error> | E e) { }