mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8317689: [JVMCI] include error message when CreateJavaVM in libgraal fails
Reviewed-by: phofer, thartmann, never
This commit is contained in:
parent
f9795d0d09
commit
8879c78d62
6 changed files with 33 additions and 13 deletions
|
@ -147,13 +147,14 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
|
|||
_is_hotspot = false;
|
||||
|
||||
_runtime = JVMCI::compiler_runtime(thread);
|
||||
_env = _runtime->init_shared_library_javavm(&_init_error);
|
||||
_env = _runtime->init_shared_library_javavm(&_init_error, &_init_error_msg);
|
||||
if (_env != nullptr) {
|
||||
// Creating the JVMCI shared library VM also attaches the current thread
|
||||
_detach_on_close = true;
|
||||
} else if (_init_error != JNI_OK) {
|
||||
// Caller creating this JVMCIEnv must handle the error.
|
||||
JVMCI_event_1("[%s:%d] Error creating libjvmci (err: %d)", _file, _line, _init_error);
|
||||
JVMCI_event_1("[%s:%d] Error creating libjvmci (err: %d, %s)", _file, _line,
|
||||
_init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg);
|
||||
return;
|
||||
} else {
|
||||
_runtime->GetEnv(thread, (void**)&parent_env, JNI_VERSION_1_2);
|
||||
|
@ -195,17 +196,17 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
|
|||
}
|
||||
|
||||
JVMCIEnv::JVMCIEnv(JavaThread* thread, JVMCICompileState* compile_state, const char* file, int line):
|
||||
_throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _compile_state(compile_state) {
|
||||
_throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(compile_state) {
|
||||
init_env_mode_runtime(thread, nullptr);
|
||||
}
|
||||
|
||||
JVMCIEnv::JVMCIEnv(JavaThread* thread, const char* file, int line):
|
||||
_throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _compile_state(nullptr) {
|
||||
_throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(nullptr) {
|
||||
init_env_mode_runtime(thread, nullptr);
|
||||
}
|
||||
|
||||
JVMCIEnv::JVMCIEnv(JavaThread* thread, JNIEnv* parent_env, const char* file, int line):
|
||||
_throw_to_caller(true), _file(file), _line(line), _init_error(JNI_OK), _compile_state(nullptr) {
|
||||
_throw_to_caller(true), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(nullptr) {
|
||||
assert(parent_env != nullptr, "npe");
|
||||
init_env_mode_runtime(thread, parent_env);
|
||||
assert(_env == nullptr || parent_env == _env, "mismatched JNIEnvironment");
|
||||
|
@ -218,6 +219,7 @@ void JVMCIEnv::init(JavaThread* thread, bool is_hotspot, const char* file, int l
|
|||
_file = file;
|
||||
_line = line;
|
||||
_init_error = JNI_OK;
|
||||
_init_error_msg = nullptr;
|
||||
if (is_hotspot) {
|
||||
_env = nullptr;
|
||||
_pop_frame_on_close = false;
|
||||
|
@ -237,7 +239,8 @@ void JVMCIEnv::check_init(JVMCI_TRAPS) {
|
|||
if (_init_error == JNI_ENOMEM) {
|
||||
JVMCI_THROW_MSG(OutOfMemoryError, "JNI_ENOMEM creating or attaching to libjvmci");
|
||||
}
|
||||
JVMCI_THROW_MSG(InternalError, err_msg("Error creating or attaching to libjvmci (err: %d)", _init_error));
|
||||
JVMCI_THROW_MSG(InternalError, err_msg("Error creating or attaching to libjvmci (err: %d, description: %s)",
|
||||
_init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg));
|
||||
}
|
||||
|
||||
void JVMCIEnv::check_init(TRAPS) {
|
||||
|
@ -247,7 +250,8 @@ void JVMCIEnv::check_init(TRAPS) {
|
|||
if (_init_error == JNI_ENOMEM) {
|
||||
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "JNI_ENOMEM creating or attaching to libjvmci");
|
||||
}
|
||||
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), err_msg("Error creating or attaching to libjvmci (err: %d)", _init_error));
|
||||
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), err_msg("Error creating or attaching to libjvmci (err: %d, description: %s)",
|
||||
_init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg));
|
||||
}
|
||||
|
||||
// Prints a pending exception (if any) and its stack trace to st.
|
||||
|
@ -572,6 +576,9 @@ jboolean JVMCIEnv::transfer_pending_exception(JavaThread* THREAD, JVMCIEnv* peer
|
|||
}
|
||||
|
||||
JVMCIEnv::~JVMCIEnv() {
|
||||
if (_init_error_msg != nullptr) {
|
||||
os::free((void*) _init_error_msg);
|
||||
}
|
||||
if (_init_error != JNI_OK) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue