# HG changeset patch # User Paul Boddie # Date 1100105224 -3600 # Node ID fe4821483813995a515fa292a1ac4dad6239b32f # Parent 1622bd94b804305a10e10719cf8d2ccac4fc00aa Added an uncaught (and hence re-raised) exception to the testCatchFinally method. Added a method with multiple exception areas. diff -r 1622bd94b804 -r fe4821483813 tests/ExceptionTest.java --- a/tests/ExceptionTest.java Wed Nov 10 17:11:44 2004 +0100 +++ b/tests/ExceptionTest.java Wed Nov 10 17:47:04 2004 +0100 @@ -55,12 +55,14 @@ return x; } - public int testCatchFinally(int x) { + public int testCatchFinally(int x) throws MyUncheckedException { try { if (x == 0) { throw new MyException(); } else if (x == 1) { throw new MyOtherException(); + } else if (x == 2) { + throw new MyUncheckedException(); } x = 1; } catch (MyException exc) { @@ -72,6 +74,29 @@ } return x; } + + public int testMultipleCatch(int x, int y) { + try { + x = testThrow(x); + } catch (MyException exc) { + x = 3; + } catch (MyOtherException exc) { + x = 2; + } catch (java.lang.Exception exc) { + x = -1; // Should be unreachable, really. + } + + try { + x += 10 * testThrow(y); + } catch (MyException exc) { + x += 30; + } catch (MyOtherException exc) { + x += 20; + } catch (java.lang.Exception exc) { + x += -10; // Should be unreachable, really. + } + return x; + } } class MyException extends java.lang.Exception { @@ -80,4 +105,7 @@ class MyOtherException extends java.lang.Exception { } +class MyUncheckedException extends java.lang.Exception { +} + // vim: tabstop=4 expandtab shiftwidth=4