From be08874935929df5f2e6ea464e995ea1bad7f22f Mon Sep 17 00:00:00 2001 From: Tobias Hartmann <thartmann@openjdk.org> Date: Wed, 17 Aug 2016 08:19:06 +0200 Subject: [PATCH] 8164091: VM fails during startup with "assert(resolved_method->method_holder()->is_linked()) failed: must be linked" Don't throw java_lang_VirtualMachineError during VM initialization. Reviewed-by: zmajo, dlong, dholmes --- hotspot/src/share/vm/oops/method.cpp | 10 +++++++++- hotspot/test/compiler/startup/StartupOutput.java | 13 ++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index 9bcf81fe0f7..f890d1d1e9b 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -54,6 +54,7 @@ #include "runtime/compilationPolicy.hpp" #include "runtime/frame.inline.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/init.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/relocator.hpp" #include "runtime/sharedRuntime.hpp" @@ -1015,7 +1016,14 @@ address Method::make_adapters(methodHandle mh, TRAPS) { // so making them eagerly shouldn't be too expensive. AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh); if (adapter == NULL ) { - THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters"); + if (!is_init_completed()) { + // Don't throw exceptions during VM initialization because java.lang.* classes + // might not have been initialized, causing problems when constructing the + // Java exception object. + vm_exit_during_initialization("Out of space in CodeCache for adapters"); + } else { + THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters"); + } } if (mh->is_shared()) { diff --git a/hotspot/test/compiler/startup/StartupOutput.java b/hotspot/test/compiler/startup/StartupOutput.java index b8cd3157d59..04e2a1a3e16 100644 --- a/hotspot/test/compiler/startup/StartupOutput.java +++ b/hotspot/test/compiler/startup/StartupOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8026949 + * @bug 8026949 8164091 * @summary Test ensures correct VM output during startup * @library /testlibrary * @modules java.base/jdk.internal.misc @@ -45,7 +45,14 @@ public class StartupOutput { pb = ProcessTools.createJavaProcessBuilder("-Xint", "-XX:+DisplayVMOutputToStdout", "-version"); out = new OutputAnalyzer(pb.start()); out.shouldNotContain("no space to run compilers"); - out.shouldHaveExitValue(0); + + pb = ProcessTools.createJavaProcessBuilder("-Xint", "-XX:ReservedCodeCacheSize=1770K", "-XX:InitialCodeCacheSize=4K", "-version"); + out = new OutputAnalyzer(pb.start()); + // The VM should not crash but may return an error message because we don't have enough space for adapters + int exitCode = out.getExitValue(); + if (exitCode != 1 && exitCode != 0) { + throw new Exception("VM crashed with exit code " + exitCode); + } } }