langtools/test/tools/javac/multicatch/T6978574.java
author hseigel
Wed, 02 Mar 2016 23:48:41 +0000
changeset 36397 c487ced7231c
parent 6354 f50c012cd1f0
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6354
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     1
/*
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     4
 *
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     8
 *
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    14
 *
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    18
 *
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    21
 * questions.
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    22
 */
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    23
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    24
/*
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    25
 * @test
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    26
 * @bug 6978574
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    27
 * @summary  return statement in try block with multi-catch causes ClassFormatError
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    28
 */
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    29
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    30
public class T6978574  {
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    31
    static class A extends Exception { }
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    32
    static class B extends Exception { }
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    33
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    34
    static void foo() throws A { throw new A(); }
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    35
    static void bar() throws B { throw new B(); }
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    36
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    37
    static void test(boolean b) {
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    38
        try {
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    39
            if (b) foo(); else bar();
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    40
            return; // This should *not* cause ClassFormatError
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    41
        } catch (final A | B e ) { caught = true; }
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    42
        return;
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    43
    }
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    44
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    45
    static boolean caught = false;
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    46
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    47
    public static void main(String[] args) {
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    48
        test(true);
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    49
        if (!caught) throw new AssertionError();
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    50
        caught = false;
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    51
        test(false);
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    52
        if (!caught) throw new AssertionError();
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    53
    }
f50c012cd1f0 6978574: return statement in try block with multi-catch causes ClassFormatError
mcimadamore
parents:
diff changeset
    54
}