test/compiler/6865265/StackOverflowBug.java

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/compiler/6865265/StackOverflowBug.java	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,89 @@
     1.4 +/*
     1.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +/**
    1.29 + * @test
    1.30 + * @bug 6865265
    1.31 + * @summary JVM crashes with "missing exception handler" error
    1.32 + * @author volker.simonis@sap.com
    1.33 + *
    1.34 + * @run main/othervm -XX:CompileThreshold=100 -Xbatch -Xss248k StackOverflowBug
    1.35 + */
    1.36 +
    1.37 +
    1.38 +public class StackOverflowBug {
    1.39 +
    1.40 +  public static int run() {
    1.41 +    try {
    1.42 +      try {
    1.43 +        return run();
    1.44 +      } catch (Throwable e) {
    1.45 +        // Notice that the class 'Throwable' is NOT resolved by the verifier,
    1.46 +        // because the verifier only checks if 'Throwable' is assignable to
    1.47 +        // 'java.lang.Throwable' and this check succeeds immediately if the two
    1.48 +        // types have equal names (see 'VerificationType::is_assignable_from' which
    1.49 +        // is called from 'ClassVerifier::verify_exception_handler_table').
    1.50 +        // This is strange, because if the two classes have different names,
    1.51 +        // 'is_assignable_from()' calls 'is_reference_assignable_from()' which resolves
    1.52 +        // both classes by calling 'SystemDictionary::resolve_or_fail()'. This call
    1.53 +        // also takes into account the current class loader (i.e. the one which was used
    1.54 +        // to load this class) and would place a corresponding
    1.55 +        // "java.lang.Throwable / current-Classloader" entry into the system dictionary.
    1.56 +        // This would in turn allow C2 to see 'java.lang.Throwable' as "loaded"
    1.57 +        // (see 'Parse::catch_inline_exceptions()') when this method is compiled.
    1.58 +        return 42;
    1.59 +      }
    1.60 +    }
    1.61 +    finally {
    1.62 +    }
    1.63 +  }
    1.64 +
    1.65 +  public static void main(String argv[]) {
    1.66 +    run();
    1.67 +  }
    1.68 +}
    1.69 +
    1.70 +/*
    1.71 +  public static int run();
    1.72 +    Code:
    1.73 +       0: invokestatic  #2                  // Method run:()I
    1.74 +       3: istore_0
    1.75 +       4: iload_0
    1.76 +       5: ireturn
    1.77 +       6: astore_0
    1.78 +       7: bipush        42
    1.79 +       9: istore_1
    1.80 +      10: iload_1
    1.81 +      11: ireturn
    1.82 +      12: astore_2
    1.83 +      13: aload_2
    1.84 +      14: athrow
    1.85 +    Exception table:
    1.86 +       from    to  target type
    1.87 +           0     4     6   Class java/lang/Throwable
    1.88 +           0     4    12   any
    1.89 +           6    10    12   any
    1.90 +          12    13    12   any
    1.91 +
    1.92 + */

mercurial