@@ -147,13 +147,14 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
147147 _is_hotspot = false ;
148148
149149 _runtime = JVMCI::compiler_runtime (thread);
150- _env = _runtime->init_shared_library_javavm (&_init_error);
150+ _env = _runtime->init_shared_library_javavm (&_init_error, &_init_error_msg );
151151 if (_env != nullptr ) {
152152 // Creating the JVMCI shared library VM also attaches the current thread
153153 _detach_on_close = true ;
154154 } else if (_init_error != JNI_OK) {
155155 // Caller creating this JVMCIEnv must handle the error.
156- JVMCI_event_1 (" [%s:%d] Error creating libjvmci (err: %d)" , _file, _line, _init_error);
156+ JVMCI_event_1 (" [%s:%d] Error creating libjvmci (err: %d, %s)" , _file, _line,
157+ _init_error, _init_error_msg == nullptr ? " unknown" : _init_error_msg);
157158 return ;
158159 } else {
159160 _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) {
195196}
196197
197198JVMCIEnv::JVMCIEnv (JavaThread* thread, JVMCICompileState* compile_state, const char * file, int line):
198- _throw_to_caller(false ), _file(file), _line(line), _init_error(JNI_OK), _compile_state(compile_state) {
199+ _throw_to_caller(false ), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg( nullptr ), _compile_state(compile_state) {
199200 init_env_mode_runtime (thread, nullptr );
200201}
201202
202203JVMCIEnv::JVMCIEnv (JavaThread* thread, const char * file, int line):
203- _throw_to_caller(false ), _file(file), _line(line), _init_error(JNI_OK), _compile_state(nullptr ) {
204+ _throw_to_caller(false ), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg( nullptr ), _compile_state(nullptr ) {
204205 init_env_mode_runtime (thread, nullptr );
205206}
206207
207208JVMCIEnv::JVMCIEnv (JavaThread* thread, JNIEnv* parent_env, const char * file, int line):
208- _throw_to_caller(true ), _file(file), _line(line), _init_error(JNI_OK), _compile_state(nullptr ) {
209+ _throw_to_caller(true ), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg( nullptr ), _compile_state(nullptr ) {
209210 assert (parent_env != nullptr , " npe" );
210211 init_env_mode_runtime (thread, parent_env);
211212 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
218219 _file = file;
219220 _line = line;
220221 _init_error = JNI_OK;
222+ _init_error_msg = nullptr ;
221223 if (is_hotspot) {
222224 _env = nullptr ;
223225 _pop_frame_on_close = false ;
@@ -237,7 +239,8 @@ void JVMCIEnv::check_init(JVMCI_TRAPS) {
237239 if (_init_error == JNI_ENOMEM) {
238240 JVMCI_THROW_MSG (OutOfMemoryError, " JNI_ENOMEM creating or attaching to libjvmci" );
239241 }
240- JVMCI_THROW_MSG (InternalError, err_msg (" Error creating or attaching to libjvmci (err: %d)" , _init_error));
242+ JVMCI_THROW_MSG (InternalError, err_msg (" Error creating or attaching to libjvmci (err: %d, description: %s)" ,
243+ _init_error, _init_error_msg == nullptr ? " unknown" : _init_error_msg));
241244}
242245
243246void JVMCIEnv::check_init (TRAPS) {
@@ -247,7 +250,8 @@ void JVMCIEnv::check_init(TRAPS) {
247250 if (_init_error == JNI_ENOMEM) {
248251 THROW_MSG (vmSymbols::java_lang_OutOfMemoryError (), " JNI_ENOMEM creating or attaching to libjvmci" );
249252 }
250- THROW_MSG (vmSymbols::java_lang_OutOfMemoryError (), err_msg (" Error creating or attaching to libjvmci (err: %d)" , _init_error));
253+ THROW_MSG (vmSymbols::java_lang_OutOfMemoryError (), err_msg (" Error creating or attaching to libjvmci (err: %d, description: %s)" ,
254+ _init_error, _init_error_msg == nullptr ? " unknown" : _init_error_msg));
251255}
252256
253257// 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
572576}
573577
574578JVMCIEnv::~JVMCIEnv () {
579+ if (_init_error_msg != nullptr ) {
580+ os::free ((void *) _init_error_msg);
581+ }
575582 if (_init_error != JNI_OK) {
576583 return ;
577584 }
0 commit comments