Fix jclass read barrier in GenericJNI.
The GcRoot<>::Read<kWithReadBarrier>() does not update
the GcRoot<>::root_ which we need to do.
Test: m
Bug: 172332525
Bug: 181249330
Change-Id: I9886c6f23339e39588c885d7b1e2557abae8d027
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 11c3820..4c67bb9 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -1947,8 +1947,12 @@
if (is_static) {
// The `jclass` is a pointer to the method's declaring class.
// The declaring class must be marked.
- method->GetDeclaringClass<kWithReadBarrier>();
- sm_.AdvancePointer(method->GetDeclaringClassAddressWithoutBarrier());
+ auto* declaring_class = reinterpret_cast<mirror::CompressedReference<mirror::Class>*>(
+ method->GetDeclaringClassAddressWithoutBarrier());
+ if (kUseReadBarrier) {
+ ReadBarrierJni(declaring_class, self);
+ }
+ sm_.AdvancePointer(declaring_class);
} // else "this" reference is already handled by QuickArgumentVisitor.
}
}