2
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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
7
* published by the Free Software Foundation.
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
27
* @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
33
static class A extends Exception {}
34
static class B extends Exception {}
35
static class C extends Exception {}
36
static class C1 extends C {}
37
static class C2 extends C {}
46
static int caughtExceptions = 0;
47
static int caughtRethrownExceptions = 0;
49
static void test(ExceptionKind ekind) throws A, C1 {
52
case A : throw new A();
53
case B : throw new B();
54
case C1: throw new C1();
55
case C2 : throw new C2();
58
catch (final C2 | B ex) {
61
catch (final C | A ex) {
67
public static void main(String[] args) {
68
for (ExceptionKind ekind : ExceptionKind.values()) {
72
catch (final C1 | A ex) {
73
caughtRethrownExceptions++;
76
if (caughtExceptions != 4 && caughtRethrownExceptions == 2) {
77
throw new AssertionError("Exception handler called " + caughtExceptions + "times" +
78
" rethrown handler called " + caughtRethrownExceptions + "times");