Mon, 06 Nov 2017 16:51:47 +0800
[Code Reorganization] remove trailing whitespace to pass jcheck test
1 /*
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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.
8 *
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).
14 *
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.
18 *
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
21 * questions.
22 */
24 /*
25 * @test
26 * @bug 8075118
27 * @summary Allow a ctor to call super() from a switch bytecode.
28 * @compile HandlerInTry.jasm
29 * @compile IsolatedHandlerInTry.jasm
30 * @run main/othervm -Xverify:all LoadHandlerInTry
31 */
33 /*
34 * This test has two cases:
35 *
36 * 1. class HandlerInTry: Class HandlerInTry contains a TRY block in a
37 * constructor whose handler is inside the same TRY block. The last
38 * few bytecodes and exception table look like this:
39 *
40 * ...
41 * 87: athrow
42 * 88: astore 4
43 * 90: invokestatic #9
44 * 93: aload 4
45 * 95: athrow
46 * 96: return
47 * Exception table:
48 * from to target type
49 * 36 46 53 Class java/lang/Throwable
50 * 36 46 88 any
51 * 53 90 88 any
52 *
53 * Note that the target for the third handler in the Exception table is
54 * inside its TRY block.
55 * Without the fix for bug JDK-8075118, this test will time out.
56 *
57 *
58 * 2. class IsolatedHandlerInTry: Class IsolatedHandlerInTry also contains
59 * a TRY block in a constructoer whose handler is inside its TRY block.
60 * But the handler is only reachable if an exception is thrown. The
61 * handler's bytecodes will not get parsed as part of parsing the TRY
62 * block. They will only get parsed as a handler for the TRY block.
63 * Since the isolated handler does a 'return', a VerifyError exception
64 * should get thrown.
65 */
67 public class LoadHandlerInTry {
69 public static void main(String[] args) throws Exception {
70 System.out.println("Regression test for bug 8075118");
71 try {
72 Class newClass = Class.forName("HandlerInTry");
73 } catch (Exception e) {
74 System.out.println("Failed: Exception was thrown: " + e.toString());
75 throw e;
76 }
78 try {
79 Class newClass = Class.forName("IsolatedHandlerInTry");
80 throw new RuntimeException(
81 "Failed to throw VerifyError for IsolatedHandlerInTry");
82 } catch (java.lang.VerifyError e) {
83 System.out.println("Passed: VerifyError exception was thrown");
84 }
85 }
86 }