mcimadamore@550: /* ohair@554: * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. mcimadamore@550: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. mcimadamore@550: * mcimadamore@550: * This code is free software; you can redistribute it and/or modify it mcimadamore@550: * under the terms of the GNU General Public License version 2 only, as mcimadamore@550: * published by the Free Software Foundation. mcimadamore@550: * mcimadamore@550: * This code is distributed in the hope that it will be useful, but WITHOUT mcimadamore@550: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or mcimadamore@550: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License mcimadamore@550: * version 2 for more details (a copy is included in the LICENSE file that mcimadamore@550: * accompanied this code). mcimadamore@550: * mcimadamore@550: * You should have received a copy of the GNU General Public License version mcimadamore@550: * 2 along with this work; if not, write to the Free Software Foundation, mcimadamore@550: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. mcimadamore@550: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. mcimadamore@550: */ mcimadamore@550: mcimadamore@550: /* mcimadamore@550: * @test mcimadamore@550: * @bug 6943289 mcimadamore@550: * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch') mcimadamore@550: * mcimadamore@550: */ mcimadamore@550: mcimadamore@550: public class Pos01 { mcimadamore@550: mcimadamore@550: static class A extends Exception {} mcimadamore@550: static class B extends Exception {} mcimadamore@550: mcimadamore@550: static int caughtExceptions = 0; mcimadamore@550: mcimadamore@550: static void test(boolean b) { mcimadamore@550: try { mcimadamore@550: if (b) { mcimadamore@550: throw new A(); mcimadamore@550: } mcimadamore@550: else { mcimadamore@550: throw new B(); mcimadamore@550: } mcimadamore@550: } mcimadamore@550: catch (final A | B ex) { mcimadamore@550: caughtExceptions++; mcimadamore@550: } mcimadamore@550: } mcimadamore@550: mcimadamore@550: public static void main(String[] args) { mcimadamore@550: test(true); mcimadamore@550: test(false); mcimadamore@550: if (caughtExceptions != 2) { mcimadamore@550: throw new AssertionError("Exception handler called " + caughtExceptions + "times"); mcimadamore@550: } mcimadamore@550: } mcimadamore@550: }