Remove the useless "suspend count already zero" message for new threads.
We can actually detect the expected case of this warning ourselves, and
not emit it. Then we can upgrade the WARNING to a FATAL.
I also tripped over the fact that the operator<< for Thread::State was out
of date, so I've moved the Thread enums up to namespace scope so the script
can automatically generate correct operator<< implementations for us. (All
the high-numbered thread states have been off by one for a couple of weeks.)
Change-Id: I5de573d33d641e5a3cba87b370e9620c8c66e633
diff --git a/src/java_lang_Thread.cc b/src/java_lang_Thread.cc
index 6ce2609..197c1b9 100644
--- a/src/java_lang_Thread.cc
+++ b/src/java_lang_Thread.cc
@@ -54,22 +54,22 @@
const jint kJavaTimedWaiting = 4;
const jint kJavaTerminated = 5;
- Thread::State internal_thread_state = (hasBeenStarted ? Thread::kTerminated : Thread::kStarting);
+ ThreadState internal_thread_state = (hasBeenStarted ? kTerminated : kStarting);
ScopedThreadListLock thread_list_lock;
Thread* thread = Thread::FromManagedThread(env, javaThread);
if (thread != NULL) {
internal_thread_state = thread->GetState();
}
switch (internal_thread_state) {
- case Thread::kTerminated: return kJavaTerminated;
- case Thread::kRunnable: return kJavaRunnable;
- case Thread::kTimedWaiting: return kJavaTimedWaiting;
- case Thread::kBlocked: return kJavaBlocked;
- case Thread::kWaiting: return kJavaWaiting;
- case Thread::kStarting: return kJavaNew;
- case Thread::kNative: return kJavaRunnable;
- case Thread::kVmWait: return kJavaWaiting;
- case Thread::kSuspended: return kJavaRunnable;
+ case kTerminated: return kJavaTerminated;
+ case kRunnable: return kJavaRunnable;
+ case kTimedWaiting: return kJavaTimedWaiting;
+ case kBlocked: return kJavaBlocked;
+ case kWaiting: return kJavaWaiting;
+ case kStarting: return kJavaNew;
+ case kNative: return kJavaRunnable;
+ case kVmWait: return kJavaWaiting;
+ case kSuspended: return kJavaRunnable;
// Don't add a 'default' here so the compiler can spot incompatible enum changes.
}
return -1; // Unreachable.
@@ -78,7 +78,7 @@
static jboolean Thread_nativeHoldsLock(JNIEnv* env, jobject javaThread, jobject javaObject) {
Object* object = Decode<Object*>(env, javaObject);
if (object == NULL) {
- ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
+ ScopedThreadStateChange tsc(Thread::Current(), kRunnable);
Thread::Current()->ThrowNewException("Ljava/lang/NullPointerException;", "object == null");
return JNI_FALSE;
}