summaryrefslogtreecommitdiff
path: root/src/native/java_lang_Thread.cc
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2012-11-26 21:00:08 -0800
committer Ian Rogers <irogers@google.com> 2012-11-30 16:38:21 -0800
commitcfaa455374aae0a08c8cb28b5bb306b17866d652 (patch)
treeca8f25a06f234385b6e62bb774085f1324e5d519 /src/native/java_lang_Thread.cc
parent3676aeb03d5f70933891bb3b21abb8e31a81e36c (diff)
Turn the thread peer_ into a Object*.
Don't use a JNI global ref for the thread peer_ so that we can support more threads than we can global refs. This fixes run-test 51. Fix a race in thread destruction where a thread may be requested to suspend while deleting itself. Change-Id: Id8756a575becf80d2a0be0a213325034556927f1
Diffstat (limited to 'src/native/java_lang_Thread.cc')
-rw-r--r--src/native/java_lang_Thread.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/native/java_lang_Thread.cc b/src/native/java_lang_Thread.cc
index cf475e280c..f14c03b4c8 100644
--- a/src/native/java_lang_Thread.cc
+++ b/src/native/java_lang_Thread.cc
@@ -25,11 +25,12 @@
namespace art {
static jobject Thread_currentThread(JNIEnv* env, jclass) {
- return reinterpret_cast<JNIEnvExt*>(env)->self->GetPeer();
+ ScopedObjectAccess soa(env);
+ return soa.AddLocalReference<jobject>(soa.Self()->GetPeer());
}
static jboolean Thread_interrupted(JNIEnv* env, jclass) {
- return reinterpret_cast<JNIEnvExt*>(env)->self->Interrupted() ? JNI_TRUE : JNI_FALSE;
+ return static_cast<JNIEnvExt*>(env)->self->Interrupted() ? JNI_TRUE : JNI_FALSE;
}
static jboolean Thread_isInterrupted(JNIEnv* env, jobject java_thread) {
@@ -108,7 +109,7 @@ static void Thread_nativeSetName(JNIEnv* env, jobject peer, jstring java_name) {
ScopedUtfChars name(env, java_name);
{
ScopedObjectAccess soa(env);
- if (soa.Env()->IsSameObject(peer, soa.Self()->GetPeer())) {
+ if (soa.Decode<Object*>(peer) == soa.Self()->GetPeer()) {
soa.Self()->SetThreadName(name.c_str());
return;
}