equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 6911256 6964740 |
26 * @bug 6911256 6964740 7013420 |
27 * @author Joseph D. Darcy |
27 * @author Joseph D. Darcy |
28 * @summary Test that TWR and multi-catch play well together |
28 * @summary Test that TWR and multi-catch play well together |
29 * @compile TwrMultiCatch.java |
29 * @compile TwrMultiCatch.java |
30 * @run main TwrMultiCatch |
30 * @run main TwrMultiCatch |
31 */ |
31 */ |
46 CustomCloseException2.class); |
46 CustomCloseException2.class); |
47 } |
47 } |
48 |
48 |
49 private static void test(TwrMultiCatch twrMultiCatch, |
49 private static void test(TwrMultiCatch twrMultiCatch, |
50 Class<? extends Exception> expected) { |
50 Class<? extends Exception> expected) { |
51 try(twrMultiCatch) { |
51 try(TwrMultiCatch tmc = twrMultiCatch) { |
52 System.out.println(twrMultiCatch.toString()); |
52 System.out.println(tmc.toString()); |
53 } catch (final CustomCloseException1 | |
53 } catch (CustomCloseException1 | |
54 CustomCloseException2 exception) { |
54 CustomCloseException2 exception) { |
55 if (!exception.getClass().equals(expected) ) { |
55 if (!exception.getClass().equals(expected) ) { |
56 throw new RuntimeException("Unexpected catch!"); |
56 throw new RuntimeException("Unexpected catch!"); |
57 } |
57 } |
58 } |
58 } |
66 throw new RuntimeException(rfe); |
66 throw new RuntimeException(rfe); |
67 } |
67 } |
68 |
68 |
69 try { |
69 try { |
70 throw t; |
70 throw t; |
71 } catch (final CustomCloseException1 | |
71 } catch (CustomCloseException1 | |
72 CustomCloseException2 exception) { |
72 CustomCloseException2 exception) { |
73 throw exception; |
73 throw exception; |
74 } catch (Throwable throwable) { |
74 } catch (Throwable throwable) { |
75 throw new RuntimeException(throwable); |
75 throw new RuntimeException(throwable); |
76 } |
76 } |