Only print IRT remove local warning if CheckJNI is enabled
Less spammy.
(cherry picked from commit c5adebc9327bd5ca223a5faf99d904cc202a1627)
Bug: 17405090
Change-Id: Ib78d0d7bc31a88182cb9d85ddba9b469bd50324b
diff --git a/runtime/indirect_reference_table.cc b/runtime/indirect_reference_table.cc
index e2b9559..0ef58ea 100644
--- a/runtime/indirect_reference_table.cc
+++ b/runtime/indirect_reference_table.cc
@@ -175,10 +175,16 @@
DCHECK(table_ != nullptr);
DCHECK_GE(segment_state_.parts.numHoles, prevState.parts.numHoles);
- if (GetIndirectRefKind(iref) == kHandleScopeOrInvalid &&
- Thread::Current()->HandleScopeContains(reinterpret_cast<jobject>(iref))) {
- LOG(WARNING) << "Attempt to remove local handle scope entry from IRT, ignoring";
- return true;
+ if (GetIndirectRefKind(iref) == kHandleScopeOrInvalid) {
+ auto* self = Thread::Current();
+ if (self->HandleScopeContains(reinterpret_cast<jobject>(iref))) {
+ auto* env = self->GetJniEnv();
+ DCHECK(env != nullptr);
+ if (env->check_jni) {
+ LOG(WARNING) << "Attempt to remove local handle scope entry from IRT, ignoring";
+ }
+ return true;
+ }
}
const int idx = ExtractIndex(iref);
if (idx < bottomIndex) {