summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-07-29 14:40:52 -0700
committerElliott Hughes <enh@google.com>2013-07-29 14:40:52 -0700
commit9dcd45c60c691524bd8ef7d6f65075d9ee3e5554 (patch)
treed27237f65c162318aed87da438431607f0a15ba6
parent46a1270fad27d81904ed60d0df56761356af500d (diff)
downloadart-9dcd45c60c691524bd8ef7d6f65075d9ee3e5554.zip
art-9dcd45c60c691524bd8ef7d6f65075d9ee3e5554.tar.gz
art-9dcd45c60c691524bd8ef7d6f65075d9ee3e5554.tar.bz2
Fix NewLocalRef to use AddLocalReference.
Bug: 10026664 Change-Id: I06f8f75a92f73b3b58fa767c0d08d1b736f7d5b5
-rw-r--r--runtime/indirect_reference_table.cc2
-rw-r--r--runtime/jni_internal.cc6
-rw-r--r--runtime/scoped_thread_state_change.h9
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_) {