Commit a7bc3130 authored by Lubomir Bulej's avatar Lubomir Bulej

Release unused local references when querying thread name

The JVMTI documentation mentions that these references
(thread_group and context_class_loader) should be managed,
so we call JNI->DeleteLocalRef() on them.
parent 5800edd8
Pipeline #3414 passed with stages
in 2 minutes and 55 seconds
...@@ -418,13 +418,22 @@ __thread_id (JNIEnv * jni) { ...@@ -418,13 +418,22 @@ __thread_id (JNIEnv * jni) {
static char * static char *
__thread_name (jvmtiEnv * jvmti) { __thread_name (jvmtiEnv * jvmti, JNIEnv * jni) {
assert (jvmti != NULL && jvm_is_initialized); assert (jvmti != NULL && jvm_is_initialized);
jvmtiThreadInfo info; jvmtiThreadInfo info;
jvmtiError error = (* jvmti)->GetThreadInfo (jvmti, NULL, &info); jvmtiError error = (* jvmti)->GetThreadInfo (jvmti, NULL, &info);
check_jvmti_error (jvmti, error, "failed to get current thread info"); check_jvmti_error (jvmti, error, "failed to get current thread info");
//
// Release the thread_group and context_class_loader
// references because we dont not need them.
//
if (jni != NULL) {
(* jni)->DeleteLocalRef (jni, info.thread_group);
(* jni)->DeleteLocalRef (jni, info.context_class_loader);
}
return info.name; return info.name;
} }
...@@ -440,7 +449,7 @@ struct thread_info { ...@@ -440,7 +449,7 @@ struct thread_info {
static void static void
__thread_info_init (jvmtiEnv * jvmti, JNIEnv * jni, struct thread_info * info) { __thread_info_init (jvmtiEnv * jvmti, JNIEnv * jni, struct thread_info * info) {
if (jvmti != NULL && jvm_is_initialized) { if (jvmti != NULL && jvm_is_initialized) {
info->name = __thread_name (jvmti); info->name = __thread_name (jvmti, jni);
} }
if (jni != NULL && jvm_is_started) { if (jni != NULL && jvm_is_started) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment