Change ArtField::ProxyFindSystemClass() to lookup the class.
As the function is called from ArtField::LookupType(),
we should avoid calls that appear to allow type resolution
rather than plain lookup. The lookup should always succeed.
Also rename ArtField::LookupType() to LookupResolvedType()
to align with naming used in ClassLinker and ArtMethod.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I0a87347b5341575e47e0fdba6d58ade2543387c8
diff --git a/runtime/art_field-inl.h b/runtime/art_field-inl.h
index 4a328e8..ae81ee8 100644
--- a/runtime/art_field-inl.h
+++ b/runtime/art_field-inl.h
@@ -299,7 +299,7 @@
return GetTypeAsPrimitiveType() != Primitive::kPrimNot;
}
-inline ObjPtr<mirror::Class> ArtField::LookupType() {
+inline ObjPtr<mirror::Class> ArtField::LookupResolvedType() {
ScopedAssertNoThreadSuspension ants(__FUNCTION__);
const uint32_t field_index = GetDexFieldIndex();
ObjPtr<mirror::Class> declaring_class = GetDeclaringClass();
diff --git a/runtime/art_field.cc b/runtime/art_field.cc
index bc728f4..54746a3 100644
--- a/runtime/art_field.cc
+++ b/runtime/art_field.cc
@@ -45,7 +45,10 @@
ObjPtr<mirror::Class> ArtField::ProxyFindSystemClass(const char* descriptor) {
DCHECK(GetDeclaringClass()->IsProxyClass());
- return Runtime::Current()->GetClassLinker()->FindSystemClass(Thread::Current(), descriptor);
+ ObjPtr<mirror::Class> klass = Runtime::Current()->GetClassLinker()->LookupClass(
+ Thread::Current(), descriptor, /* class_loader */ nullptr);
+ DCHECK(klass != nullptr);
+ return klass;
}
ObjPtr<mirror::String> ArtField::ResolveGetStringName(Thread* self,
diff --git a/runtime/art_field.h b/runtime/art_field.h
index 866bf0b..a6f0508 100644
--- a/runtime/art_field.h
+++ b/runtime/art_field.h
@@ -205,7 +205,7 @@
bool IsPrimitiveType() REQUIRES_SHARED(Locks::mutator_lock_);
- ObjPtr<mirror::Class> LookupType() REQUIRES_SHARED(Locks::mutator_lock_);
+ ObjPtr<mirror::Class> LookupResolvedType() REQUIRES_SHARED(Locks::mutator_lock_);
ObjPtr<mirror::Class> ResolveType() REQUIRES_SHARED(Locks::mutator_lock_);
size_t FieldSize() REQUIRES_SHARED(Locks::mutator_lock_);
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index e5bb786..71b6378 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -8659,10 +8659,10 @@
DCHECK_EQ(h_dex_element_class.Get(), element_file_field->GetDeclaringClass());
ArtField* cookie_field = jni::DecodeArtField(WellKnownClasses::dalvik_system_DexFile_cookie);
- DCHECK_EQ(cookie_field->GetDeclaringClass(), element_file_field->LookupType());
+ DCHECK_EQ(cookie_field->GetDeclaringClass(), element_file_field->LookupResolvedType());
ArtField* file_name_field = jni::DecodeArtField(WellKnownClasses::dalvik_system_DexFile_fileName);
- DCHECK_EQ(file_name_field->GetDeclaringClass(), element_file_field->LookupType());
+ DCHECK_EQ(file_name_field->GetDeclaringClass(), element_file_field->LookupResolvedType());
// Fill the elements array.
int32_t index = 0;
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index 87cc620..97fb793 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -240,7 +240,7 @@
CHECK_NE(field.GetTypeAsPrimitiveType(), Primitive::kPrimNot);
// TODO: resolve the field type for moving GC.
ObjPtr<mirror::Class> field_type =
- kMovingCollector ? field.LookupType() : field.ResolveType();
+ kMovingCollector ? field.LookupResolvedType() : field.ResolveType();
if (field_type != nullptr) {
CHECK(field_type->IsAssignableFrom(new_value->GetClass()));
}
@@ -258,7 +258,7 @@
CHECK_NE(field.GetTypeAsPrimitiveType(), Primitive::kPrimNot);
// TODO: resolve the field type for moving GC.
ObjPtr<mirror::Class> field_type =
- kMovingCollector ? field.LookupType() : field.ResolveType();
+ kMovingCollector ? field.LookupResolvedType() : field.ResolveType();
if (field_type != nullptr) {
CHECK(field_type->IsAssignableFrom(new_value->GetClass()));
}
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index fefb4f6..25982cf 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -5046,7 +5046,7 @@
}
ObjPtr<mirror::Class> field_type_class =
- can_load_classes_ ? field->ResolveType() : field->LookupType();
+ can_load_classes_ ? field->ResolveType() : field->LookupResolvedType();
if (field_type_class != nullptr) {
field_type = &FromClass(field->GetTypeDescriptor(),
field_type_class.Ptr(),
@@ -5195,7 +5195,7 @@
const RegType* field_type;
{
ObjPtr<mirror::Class> field_type_class =
- can_load_classes_ ? field->ResolveType() : field->LookupType();
+ can_load_classes_ ? field->ResolveType() : field->LookupResolvedType();
if (field_type_class != nullptr) {
field_type = &FromClass(field->GetTypeDescriptor(),