Path: blob/master/test/hotspot/jtreg/compiler/runtime/StackOverflowBug.java
41152 views
/*1* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 686526526* @summary JVM crashes with "missing exception handler" error27* @author [email protected]28*29* @run main/othervm -XX:CompileThreshold=100 -Xbatch -Xss512k30* compiler.runtime.StackOverflowBug31*/3233package compiler.runtime;3435public class StackOverflowBug {3637public static int run() {38try {39try {40return run();41} catch (Throwable e) {42// Notice that the class 'Throwable' is NOT resolved by the verifier,43// because the verifier only checks if 'Throwable' is assignable to44// 'java.lang.Throwable' and this check succeeds immediately if the two45// types have equal names (see 'VerificationType::is_assignable_from' which46// is called from 'ClassVerifier::verify_exception_handler_table').47// This is strange, because if the two classes have different names,48// 'is_assignable_from()' calls 'is_reference_assignable_from()' which resolves49// both classes by calling 'SystemDictionary::resolve_or_fail()'. This call50// also takes into account the current class loader (i.e. the one which was used51// to load this class) and would place a corresponding52// "java.lang.Throwable / current-Classloader" entry into the system dictionary.53// This would in turn allow C2 to see 'java.lang.Throwable' as "loaded"54// (see 'Parse::catch_inline_exceptions()') when this method is compiled.55return 42;56}57} finally {58}59}6061public static void main(String argv[]) {62run();63}64}6566/*67public static int run();68Code:690: invokestatic #2 // Method run:()I703: istore_0714: iload_0725: ireturn736: astore_0747: bipush 42759: istore_17610: iload_17711: ireturn7812: astore_27913: aload_28014: athrow81Exception table:82from to target type830 4 6 Class java/lang/Throwable840 4 12 any856 10 12 any8612 13 12 any8788*/899091