From c316ecf04918c623bd9109f20c2ae64f996e53cd Mon Sep 17 00:00:00 2001 From: Pavel Afremov Date: Thu, 13 Sep 2007 17:09:28 +0400 Subject: [PATCH] Fix of isAlive during JVM TI THREAD_START event processing. Source of the bug is in independent java isAlive thread state and JVMTI, hythread state. This issue is planed to fix see HARMONY-4716 and HARMONY-4644. To fix test noted in the JIRA patch synchronizes java isAlive state with JVMTI, hythread state, before invoke jvmti_send_thread_start_end_event(1). --- vm/vmcore/src/thread/thread_java_basic.cpp | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/vm/vmcore/src/thread/thread_java_basic.cpp b/vm/vmcore/src/thread/thread_java_basic.cpp index 842304b..2c4dd0b 100644 --- a/vm/vmcore/src/thread/thread_java_basic.cpp +++ b/vm/vmcore/src/thread/thread_java_basic.cpp @@ -30,6 +30,7 @@ #include "cxxlog.h" static jmethodID jthread_get_run_method(JNIEnv * env, jthread java_thread); +static jfieldID jthread_get_alive_field(JNIEnv * env, jthread java_thread); static IDATA jthread_associate_native_and_java_thread(JNIEnv * env, jthread java_thread, hythread_t native_thread, jobject weak_ref); @@ -81,6 +82,9 @@ static IDATA HYTHREAD_PROC jthread_wrapper_proc(void *arg) } // Send Thread Start event. + assert(hythread_is_alive(native_thread)); + jni_env->SetBooleanField(java_thread, + jthread_get_alive_field(jni_env, java_thread), true); jvmti_send_thread_start_end_event(1); jthread_start_count(); @@ -202,6 +206,7 @@ IDATA jthread_attach(JNIEnv *jni_env, jthread java_thread, jboolean daemon) } // Send Thread Start event. + assert(hythread_is_alive(native_thread)); jvmti_send_thread_start_end_event(1); jthread_start_count(); @@ -667,3 +672,16 @@ static jmethodID jthread_get_run_method(JNIEnv * env, jthread java_thread) return run_method; } // jthread_get_run_method +static jfieldID jthread_get_alive_field(JNIEnv * env, jthread java_thread) +{ + static jfieldID alive_field = NULL; + + TRACE("run method find enter"); + if (!alive_field) { + jclass clazz = env->GetObjectClass(java_thread); + alive_field = env->GetFieldID(clazz, "isAlive", "Z"); + } + TRACE("run method find exit"); + return alive_field; +} // jthread_get_run_method + -- 1.5.0.3