Create JNIEnv*s on the right threads.
This exposes a bug in jni_compiler.cc --- it passes the right JNIEnv* to the
native method and to MonitorExit, but it passes a bogus value to MonitorEnter.
Change-Id: Icbf505d24294d14ce3e40180a20254789cb69904
diff --git a/src/thread.cc b/src/thread.cc
index 68f4566..b98d1e5 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -101,6 +101,8 @@
PLOG(FATAL) << "pthread_setspecific failed";
}
+ thread->jni_env_ = CreateJNIEnv();
+
return thread;
}
@@ -144,6 +146,14 @@
return os;
}
+std::ostream& operator<<(std::ostream& os, const Thread& thread) {
+ os << "Thread[" << &thread
+ << ",id=" << thread.GetId()
+ << ",tid=" << thread.GetNativeId()
+ << ",state=" << thread.GetState() << "]";
+ return os;
+}
+
ThreadList* ThreadList::Create() {
return new ThreadList;
}