test/runtime/handlerInTry/LoadHandlerInTry.java

Mon, 06 Nov 2017 16:51:47 +0800

author
aoqi
date
Mon, 06 Nov 2017 16:51:47 +0800
changeset 7997
6cbff0651f1a
parent 7643
695017a614d5
child 8703
02a3d0dcbedd
permissions
-rw-r--r--

[Code Reorganization] remove trailing whitespace to pass jcheck test

hseigel@7643 1 /*
hseigel@7643 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
hseigel@7643 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hseigel@7643 4 *
hseigel@7643 5 * This code is free software; you can redistribute it and/or modify it
hseigel@7643 6 * under the terms of the GNU General Public License version 2 only, as
hseigel@7643 7 * published by the Free Software Foundation.
hseigel@7643 8 *
hseigel@7643 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hseigel@7643 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hseigel@7643 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hseigel@7643 12 * version 2 for more details (a copy is included in the LICENSE file that
hseigel@7643 13 * accompanied this code).
hseigel@7643 14 *
hseigel@7643 15 * You should have received a copy of the GNU General Public License version
hseigel@7643 16 * 2 along with this work; if not, write to the Free Software Foundation,
hseigel@7643 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hseigel@7643 18 *
hseigel@7643 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hseigel@7643 20 * or visit www.oracle.com if you need additional information or have any
hseigel@7643 21 * questions.
hseigel@7643 22 */
hseigel@7643 23
hseigel@7643 24 /*
hseigel@7643 25 * @test
hseigel@7643 26 * @bug 8075118
hseigel@7643 27 * @summary Allow a ctor to call super() from a switch bytecode.
hseigel@7643 28 * @compile HandlerInTry.jasm
hseigel@7643 29 * @compile IsolatedHandlerInTry.jasm
hseigel@7643 30 * @run main/othervm -Xverify:all LoadHandlerInTry
hseigel@7643 31 */
hseigel@7643 32
hseigel@7643 33 /*
hseigel@7643 34 * This test has two cases:
hseigel@7643 35 *
hseigel@7643 36 * 1. class HandlerInTry: Class HandlerInTry contains a TRY block in a
hseigel@7643 37 * constructor whose handler is inside the same TRY block. The last
hseigel@7643 38 * few bytecodes and exception table look like this:
hseigel@7643 39 *
hseigel@7643 40 * ...
hseigel@7643 41 * 87: athrow
hseigel@7643 42 * 88: astore 4
hseigel@7643 43 * 90: invokestatic #9
hseigel@7643 44 * 93: aload 4
hseigel@7643 45 * 95: athrow
hseigel@7643 46 * 96: return
hseigel@7643 47 * Exception table:
hseigel@7643 48 * from to target type
hseigel@7643 49 * 36 46 53 Class java/lang/Throwable
hseigel@7643 50 * 36 46 88 any
hseigel@7643 51 * 53 90 88 any
hseigel@7643 52 *
hseigel@7643 53 * Note that the target for the third handler in the Exception table is
hseigel@7643 54 * inside its TRY block.
hseigel@7643 55 * Without the fix for bug JDK-8075118, this test will time out.
hseigel@7643 56 *
hseigel@7643 57 *
hseigel@7643 58 * 2. class IsolatedHandlerInTry: Class IsolatedHandlerInTry also contains
hseigel@7643 59 * a TRY block in a constructoer whose handler is inside its TRY block.
hseigel@7643 60 * But the handler is only reachable if an exception is thrown. The
hseigel@7643 61 * handler's bytecodes will not get parsed as part of parsing the TRY
hseigel@7643 62 * block. They will only get parsed as a handler for the TRY block.
hseigel@7643 63 * Since the isolated handler does a 'return', a VerifyError exception
hseigel@7643 64 * should get thrown.
hseigel@7643 65 */
hseigel@7643 66
hseigel@7643 67 public class LoadHandlerInTry {
hseigel@7643 68
hseigel@7643 69 public static void main(String[] args) throws Exception {
hseigel@7643 70 System.out.println("Regression test for bug 8075118");
hseigel@7643 71 try {
hseigel@7643 72 Class newClass = Class.forName("HandlerInTry");
hseigel@7643 73 } catch (Exception e) {
hseigel@7643 74 System.out.println("Failed: Exception was thrown: " + e.toString());
hseigel@7643 75 throw e;
hseigel@7643 76 }
hseigel@7643 77
hseigel@7643 78 try {
hseigel@7643 79 Class newClass = Class.forName("IsolatedHandlerInTry");
hseigel@7643 80 throw new RuntimeException(
hseigel@7643 81 "Failed to throw VerifyError for IsolatedHandlerInTry");
hseigel@7643 82 } catch (java.lang.VerifyError e) {
hseigel@7643 83 System.out.println("Passed: VerifyError exception was thrown");
hseigel@7643 84 }
hseigel@7643 85 }
hseigel@7643 86 }

mercurial