Use JNI to start the daemon threads.
Avoids manually messing with thread state, which I feel we're doing too
much of.
Change-Id: Ie75b7545ad473346bfa5a4694146e6d84a7cfbe6
diff --git a/src/runtime.cc b/src/runtime.cc
index e1950f3..424b6f7 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -373,11 +373,13 @@
void Runtime::StartDaemonThreads() {
signal_catcher_ = new SignalCatcher;
- Class* c = class_linker_->FindSystemClass("Ljava/lang/Daemons;");
+ Thread* self = Thread::Current();
+ JNIEnv* env = self->GetJniEnv();
+ jclass c = env->FindClass("java/lang/Daemons");
CHECK(c != NULL);
- Method* m = c->FindDirectMethod("start", "()V");
- CHECK(m != NULL);
- m->Invoke(Thread::Current(), NULL, NULL, NULL);
+ jmethodID mid = env->GetStaticMethodID(c, "start", "()V");
+ CHECK(mid != NULL);
+ env->CallStaticVoidMethod(c, mid);
}
bool Runtime::IsStarted() {