ObjPtr<>-ify mirror::Object::As*(), fix stale refs in test.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: Ia04c4996f5cbfa1f26acbadcd747342c57b1aac3
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 1a611df..7a565bd 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -3226,7 +3226,7 @@
// Print which field of the object is dead.
if (!obj->IsObjectArray()) {
- mirror::Class* klass = is_static ? obj->AsClass() : obj->GetClass();
+ ObjPtr<mirror::Class> klass = is_static ? obj->AsClass() : obj->GetClass();
CHECK(klass != nullptr);
for (ArtField& field : (is_static ? klass->GetSFields() : klass->GetIFields())) {
if (field.GetOffset().Int32Value() == offset.Int32Value()) {
@@ -3236,7 +3236,7 @@
}
}
} else {
- mirror::ObjectArray<mirror::Object>* object_array =
+ ObjPtr<mirror::ObjectArray<mirror::Object>> object_array =
obj->AsObjectArray<mirror::Object>();
for (int32_t i = 0; i < object_array->GetLength(); ++i) {
if (object_array->Get(i) == ref) {