* src/native/vm/openjdk/jvm.cpp (JVM_IsInterrupted): Fixed for threads which
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 17 Dec 2008 22:45:14 +0000 (23:45 +0100)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 17 Dec 2008 22:45:14 +0000 (23:45 +0100)
have not been started yet.
* src/native/vm/gnuclasspath/java_lang_VMThread.cpp: Added assertions to
clearly detect race-conditions.

src/native/vm/gnuclasspath/java_lang_VMThread.cpp
src/native/vm/openjdk/jvm.cpp

index 6d8b88b1835a12b288906616bb21b9bdbbacb541..da561ab5aae1e30e7adc637f185475a33539a3b0 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 
+#include <assert.h>
 #include <stdint.h>
 
 #include "native/jni.hpp"
@@ -56,7 +57,7 @@ JNIEXPORT jint JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, job
 {
        log_println("Java_java_lang_VMThread_countStackFrames: Deprecated.  Not implemented.");
 
-    return 0;
+       return 0;
 }
 
 
@@ -88,6 +89,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, jobject _t
 
        h = (java_handle_t *) _this;
        t = thread_get_thread(h);
+       assert(t != NULL);
 
        threads_thread_interrupt(t);
 #endif
@@ -107,6 +109,7 @@ JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, jo
 
        h = (java_handle_t *) _this;
        t = thread_get_thread(h);
+       assert(t != NULL);
 
        return thread_is_interrupted(t);
 #else
@@ -154,6 +157,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, jo
 
        h = (java_handle_t *) _this;
        t = thread_get_thread(h);
+       assert(t != NULL);
 
        threads_set_thread_priority(t->tid, priority);
 #endif
@@ -279,6 +283,7 @@ JNIEXPORT jstring JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, jobject
 
        h = (java_handle_t *) _this;
        t = thread_get_thread(h);
+       assert(t != NULL);
 
        state = cacaothread_get_state(t);
        
index c137d35db0d9af992665e17d61502169f1e9d691..cc431263185f5366f223875e3ac581068eef4c7a 100644 (file)
@@ -2133,8 +2133,7 @@ jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread)
        h = (java_handle_t *) jthread;
        t = thread_get_thread(h);
 
-       /* The threadobject is null when a thread is created in Java. The
-          priority is set later during startup. */
+       /* The threadobject is null when a thread is created in Java. */
 
        if (t == NULL)
                return 0;
@@ -2239,6 +2238,8 @@ void JVM_Interrupt(JNIEnv* env, jobject jthread)
        h = (java_handle_t *) jthread;
        t = thread_get_thread(h);
 
+       /* The threadobject is null when a thread is created in Java. */
+
        if (t == NULL)
                return;
 
@@ -2259,6 +2260,11 @@ jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrup
        h = (java_handle_t *) jthread;
        t = thread_get_thread(h);
 
+       /* The threadobject is null when a thread is created in Java. */
+
+       if (t == NULL)
+               return JNI_FALSE;
+
        interrupted = thread_is_interrupted(t);
 
        if (interrupted && clear_interrupted)
@@ -3257,6 +3263,7 @@ jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threa
                // Get thread for the given thread object.
                threadobject* t = thread_get_thread(thread);
 
+               // The threadobject is null when a thread is created in Java.
                if (t == NULL)
                        continue;