@@ -147,13 +147,14 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
147
147
_is_hotspot = false ;
148
148
149
149
_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 );
151
151
if (_env != nullptr ) {
152
152
// Creating the JVMCI shared library VM also attaches the current thread
153
153
_detach_on_close = true ;
154
154
} else if (_init_error != JNI_OK) {
155
155
// 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);
157
158
return ;
158
159
} else {
159
160
_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) {
195
196
}
196
197
197
198
JVMCIEnv::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) {
199
200
init_env_mode_runtime (thread, nullptr );
200
201
}
201
202
202
203
JVMCIEnv::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 ) {
204
205
init_env_mode_runtime (thread, nullptr );
205
206
}
206
207
207
208
JVMCIEnv::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 ) {
209
210
assert (parent_env != nullptr , " npe" );
210
211
init_env_mode_runtime (thread, parent_env);
211
212
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
218
219
_file = file;
219
220
_line = line;
220
221
_init_error = JNI_OK;
222
+ _init_error_msg = nullptr ;
221
223
if (is_hotspot) {
222
224
_env = nullptr ;
223
225
_pop_frame_on_close = false ;
@@ -237,7 +239,8 @@ void JVMCIEnv::check_init(JVMCI_TRAPS) {
237
239
if (_init_error == JNI_ENOMEM) {
238
240
JVMCI_THROW_MSG (OutOfMemoryError, " JNI_ENOMEM creating or attaching to libjvmci" );
239
241
}
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));
241
244
}
242
245
243
246
void JVMCIEnv::check_init (TRAPS) {
@@ -247,7 +250,8 @@ void JVMCIEnv::check_init(TRAPS) {
247
250
if (_init_error == JNI_ENOMEM) {
248
251
THROW_MSG (vmSymbols::java_lang_OutOfMemoryError (), " JNI_ENOMEM creating or attaching to libjvmci" );
249
252
}
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));
251
255
}
252
256
253
257
// 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
572
576
}
573
577
574
578
JVMCIEnv::~JVMCIEnv () {
579
+ if (_init_error_msg != nullptr ) {
580
+ os::free ((void *) _init_error_msg);
581
+ }
575
582
if (_init_error != JNI_OK) {
576
583
return ;
577
584
}
1 commit comments
openjdk-notifier[bot] commentedon Oct 24, 2023
Review
Issues