test/compiler/8015436/Test8015436.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 5215
2f004f9dc9e1
child 6876
710a3c8b516e
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

sspitsyn@5209 1 /*
sspitsyn@5209 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
sspitsyn@5209 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sspitsyn@5209 4 *
sspitsyn@5209 5 * This code is free software; you can redistribute it and/or modify it
sspitsyn@5209 6 * under the terms of the GNU General Public License version 2 only, as
sspitsyn@5209 7 * published by the Free Software Foundation.
sspitsyn@5209 8 *
sspitsyn@5209 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sspitsyn@5209 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sspitsyn@5209 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sspitsyn@5209 12 * version 2 for more details (a copy is included in the LICENSE file that
sspitsyn@5209 13 * accompanied this code).
sspitsyn@5209 14 *
sspitsyn@5209 15 * You should have received a copy of the GNU General Public License version
sspitsyn@5209 16 * 2 along with this work; if not, write to the Free Software Foundation,
sspitsyn@5209 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sspitsyn@5209 18 *
sspitsyn@5209 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sspitsyn@5209 20 * or visit www.oracle.com if you need additional information or have any
sspitsyn@5209 21 * questions.
sspitsyn@5209 22 */
sspitsyn@5209 23
sspitsyn@5209 24 /*
sspitsyn@5209 25 * @test
sspitsyn@5209 26 * @bug 8015436
sspitsyn@5209 27 * @summary the IK _initial_method_idnum value must be adjusted if overpass methods are added
sspitsyn@5209 28 * @run main Test8015436
sspitsyn@5209 29 *
sspitsyn@5209 30 */
sspitsyn@5209 31
sspitsyn@5209 32 /*
sspitsyn@5209 33 * The test checks that a MemberName for the defaultMethod() is cached in
sspitsyn@5209 34 * the class MemberNameTable without a crash in the VM fastdebug mode.
sspitsyn@5209 35 * The original issue was that the InstanceKlass _initial_method_idnum was
sspitsyn@5209 36 * not adjusted properly when the overpass methods are added to the class.
sspitsyn@5209 37 * The expected/correct behavior: The test does not crash nor throw any exceptions.
sspitsyn@5209 38 * All the invocations of the defaultMethod() must be completed successfully.
sspitsyn@5209 39 */
sspitsyn@5209 40
sspitsyn@5209 41 import java.lang.invoke.*;
sspitsyn@5209 42
sspitsyn@5209 43 interface InterfaceWithDefaultMethod {
sspitsyn@5209 44 public void someMethod();
sspitsyn@5209 45
sspitsyn@5209 46 default public void defaultMethod(String str){
sspitsyn@5209 47 System.out.println("defaultMethod() " + str);
sspitsyn@5209 48 }
sspitsyn@5209 49 }
sspitsyn@5209 50
sspitsyn@5215 51 public class Test8015436 implements InterfaceWithDefaultMethod {
sspitsyn@5209 52 @Override
sspitsyn@5209 53 public void someMethod() {
sspitsyn@5209 54 System.out.println("someMethod() invoked");
sspitsyn@5209 55 }
sspitsyn@5209 56
sspitsyn@5209 57 public static void main(String[] args) throws Throwable {
sspitsyn@5209 58 Test8015436 testObj = new Test8015436();
sspitsyn@5209 59 testObj.someMethod();
sspitsyn@5209 60 testObj.defaultMethod("invoked directly");
sspitsyn@5209 61
sspitsyn@5209 62 MethodHandles.Lookup lookup = MethodHandles.lookup();
sspitsyn@5209 63 MethodType mt = MethodType.methodType(void.class, String.class);
sspitsyn@5209 64 MethodHandle mh = lookup.findVirtual(Test8015436.class, "defaultMethod", mt);
sspitsyn@5209 65 mh.invokeExact(testObj, "invoked via a MethodHandle");
sspitsyn@5209 66 }
sspitsyn@5209 67 }
sspitsyn@5209 68
sspitsyn@5209 69 /*
sspitsyn@5209 70 * A successful execution gives the output:
sspitsyn@5209 71 * someMethod() invoked
sspitsyn@5209 72 * defaultMethod() invoked directly
sspitsyn@5209 73 * defaultMethod() invoked via a MethodHandle
sspitsyn@5209 74 */

mercurial