diff options
-rw-r--r-- | runtime/indirect_reference_table.cc | 2 | ||||
-rw-r--r-- | runtime/jni_internal.cc | 6 | ||||
-rw-r--r-- | runtime/scoped_thread_state_change.h | 9 |
3 files changed, 4 insertions, 13 deletions
diff --git a/runtime/indirect_reference_table.cc b/runtime/indirect_reference_table.cc index 0616d28..3e75716 100644 --- a/runtime/indirect_reference_table.cc +++ b/runtime/indirect_reference_table.cc @@ -237,7 +237,7 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) { mirror::Object* direct_pointer = reinterpret_cast<mirror::Object*>(iref); idx = Find(direct_pointer, bottomIndex, topIndex, table_); if (idx == -1) { - LOG(WARNING) << "trying to work around app JNI bugs, but didn't find " << iref << " in table!"; + LOG(WARNING) << "Trying to work around app JNI bugs, but didn't find " << iref << " in table!"; return false; } } diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index 858ac34..6681d56 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -833,11 +833,7 @@ class JNI { return NULL; } ScopedObjectAccess soa(env); - IndirectReferenceTable& locals = soa.Env()->locals; - - uint32_t cookie = soa.Env()->local_ref_cookie; - IndirectRef ref = locals.Add(cookie, soa.Decode<Object*>(obj)); - return reinterpret_cast<jobject>(ref); + return soa.AddLocalReference<jobject>(soa.Decode<Object*>(obj)); } static void DeleteLocalRef(JNIEnv* env, jobject obj) { diff --git a/runtime/scoped_thread_state_change.h b/runtime/scoped_thread_state_change.h index 853d684..965e6b8 100644 --- a/runtime/scoped_thread_state_change.h +++ b/runtime/scoped_thread_state_change.h @@ -154,16 +154,11 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { /* * Add a local reference for an object to the indirect reference table associated with the * current stack frame. When the native function returns, the reference will be discarded. - * Part of the ScopedJniThreadState as native code shouldn't be working on raw Object* without - * having transitioned its state. * - * We need to allow the same reference to be added multiple times. + * We need to allow the same reference to be added multiple times, and cope with NULL. * - * This will be called on otherwise unreferenced objects. We cannot do GC allocations here, and + * This will be called on otherwise unreferenced objects. We cannot do GC allocations here, and * it's best if we don't grab a mutex. - * - * Returns the local reference (currently just the same pointer that was - * passed in), or NULL on failure. */ template<typename T> T AddLocalReference(mirror::Object* obj) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |