Add more VerifyObject calls.
Added verify object calls to SirtRef, IndirectReferenceTable,
ReferenceTable.
Removed un-needed verify object in ScopedObjectAccess / DecodeJObject
since object sources are handled.
Bug: 12934910
Change-Id: I55a46a8ea61fed2a77526eda27fd2cce97a9b125
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index 4fad5c9..f8865ea 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -2537,11 +2537,13 @@
IndirectRef ref = reinterpret_cast<IndirectRef>(java_object);
IndirectRefKind kind = GetIndirectRefKind(ref);
switch (kind) {
- case kLocal:
+ case kLocal: {
+ ScopedObjectAccess soa(env);
if (static_cast<JNIEnvExt*>(env)->locals.Get(ref) != kInvalidIndirectRefObject) {
return JNILocalRefType;
}
return JNIInvalidRefType;
+ }
case kGlobal:
return JNIGlobalRefType;
case kWeakGlobal:
@@ -3192,7 +3194,11 @@
while (UNLIKELY(!allow_new_weak_globals_)) {
weak_globals_add_condition_.WaitHoldingLocks(self);
}
- return const_cast<mirror::Object*>(weak_globals_.Get(ref));
+ mirror::Object* obj = weak_globals_.Get(ref);
+ if (obj != kClearedJniWeakGlobal) {
+ VerifyObject(obj);
+ }
+ return obj;
}
void JavaVMExt::DumpReferenceTables(std::ostream& os) {