diff options
Diffstat (limited to 'runtime/class_linker.cc')
| -rw-r--r-- | runtime/class_linker.cc | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 1134e20369..f0c9507ca0 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -897,15 +897,11 @@ bool ClassLinker::InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> b object_array_class->GetIfTable()->SetInterface(0, java_lang_Cloneable.Get()); object_array_class->GetIfTable()->SetInterface(1, java_io_Serializable.Get()); - // Check Class[] and Object[]'s interfaces. GetDirectInterface may cause thread suspension. - CHECK_EQ(java_lang_Cloneable.Get(), - mirror::Class::GetDirectInterface(self, class_array_class.Get(), 0)); - CHECK_EQ(java_io_Serializable.Get(), - mirror::Class::GetDirectInterface(self, class_array_class.Get(), 1)); - CHECK_EQ(java_lang_Cloneable.Get(), - mirror::Class::GetDirectInterface(self, object_array_class.Get(), 0)); - CHECK_EQ(java_io_Serializable.Get(), - mirror::Class::GetDirectInterface(self, object_array_class.Get(), 1)); + // Check Class[] and Object[]'s interfaces. + CHECK_EQ(java_lang_Cloneable.Get(), class_array_class->GetDirectInterface(0)); + CHECK_EQ(java_io_Serializable.Get(), class_array_class->GetDirectInterface(1)); + CHECK_EQ(java_lang_Cloneable.Get(), object_array_class->GetDirectInterface(0)); + CHECK_EQ(java_io_Serializable.Get(), object_array_class->GetDirectInterface(1)); CHECK_EQ(object_array_string.Get(), FindSystemClass(self, GetClassRootDescriptor(ClassRoot::kJavaLangStringArrayClass))); @@ -1859,10 +1855,9 @@ static void VerifyAppImage(const ImageHeader& header, return true; }; class_table->Visit(verify_direct_interfaces_in_table); - Thread* self = Thread::Current(); for (ObjPtr<mirror::Class> klass : classes) { for (uint32_t i = 0, num = klass->NumDirectInterfaces(); i != num; ++i) { - CHECK(klass->GetDirectInterface(self, klass, i) != nullptr) + CHECK(klass->GetDirectInterface(i) != nullptr) << klass->PrettyDescriptor() << " iface #" << i; } } @@ -5414,7 +5409,7 @@ bool ClassLinker::InitializeClass(Thread* self, StackHandleScope<1> hs_iface(self); MutableHandle<mirror::Class> handle_scope_iface(hs_iface.NewHandle<mirror::Class>(nullptr)); for (size_t i = 0; i < num_direct_interfaces; i++) { - handle_scope_iface.Assign(mirror::Class::GetDirectInterface(self, klass.Get(), i)); + handle_scope_iface.Assign(klass->GetDirectInterface(i)); CHECK(handle_scope_iface != nullptr) << klass->PrettyDescriptor() << " iface #" << i; CHECK(handle_scope_iface->IsInterface()); if (handle_scope_iface->HasBeenRecursivelyInitialized()) { @@ -5567,7 +5562,7 @@ bool ClassLinker::InitializeDefaultInterfaceRecursive(Thread* self, MutableHandle<mirror::Class> handle_super_iface(hs.NewHandle<mirror::Class>(nullptr)); // First we initialize all of iface's super-interfaces recursively. for (size_t i = 0; i < num_direct_ifaces; i++) { - ObjPtr<mirror::Class> super_iface = mirror::Class::GetDirectInterface(self, iface.Get(), i); + ObjPtr<mirror::Class> super_iface = iface->GetDirectInterface(i); CHECK(super_iface != nullptr) << iface->PrettyDescriptor() << " iface #" << i; if (!super_iface->HasBeenRecursivelyInitialized()) { // Recursive step @@ -7198,8 +7193,7 @@ static bool NotSubinterfaceOfAny( // super_ifcount entries filled in with the transitive closure of the interfaces of the superclass. // The other entries are uninitialized. We will fill in the remaining entries in this function. The // iftable must be large enough to hold all interfaces without changing its size. -static size_t FillIfTable(Thread* self, - ObjPtr<mirror::Class> klass, +static size_t FillIfTable(ObjPtr<mirror::Class> klass, ObjPtr<mirror::ObjectArray<mirror::Class>> interfaces, ObjPtr<mirror::IfTable> iftable, size_t super_ifcount, @@ -7220,9 +7214,8 @@ static size_t FillIfTable(Thread* self, size_t filled_ifcount = super_ifcount; const bool have_interfaces = interfaces != nullptr; for (size_t i = 0; i != num_interfaces; ++i) { - ObjPtr<mirror::Class> interface = have_interfaces - ? interfaces->Get(i) - : mirror::Class::GetDirectInterface(self, klass, i); + ObjPtr<mirror::Class> interface = + have_interfaces ? interfaces->Get(i) : klass->GetDirectInterface(i); // Let us call the first filled_ifcount elements of iftable the current-iface-list. // At this point in the loop current-iface-list has the invariant that: @@ -7314,9 +7307,8 @@ bool ClassLinker::SetupInterfaceLookupTable(Thread* self, size_t ifcount = super_ifcount + num_interfaces; // Check that every class being implemented is an interface. for (size_t i = 0; i < num_interfaces; i++) { - ObjPtr<mirror::Class> interface = have_interfaces - ? interfaces->GetWithoutChecks(i) - : mirror::Class::GetDirectInterface(self, klass.Get(), i); + ObjPtr<mirror::Class> interface = + have_interfaces ? interfaces->GetWithoutChecks(i) : klass->GetDirectInterface(i); DCHECK(interface != nullptr); if (UNLIKELY(!interface->IsInterface())) { std::string temp; @@ -7348,8 +7340,8 @@ bool ClassLinker::SetupInterfaceLookupTable(Thread* self, // doesn't really do anything. self->AllowThreadSuspension(); - const size_t new_ifcount = FillIfTable( - self, klass.Get(), interfaces.Get(), iftable.Get(), super_ifcount, num_interfaces); + const size_t new_ifcount = + FillIfTable(klass.Get(), interfaces.Get(), iftable.Get(), super_ifcount, num_interfaces); self->AllowThreadSuspension(); @@ -9326,18 +9318,15 @@ ArtField* ClassLinker::FindResolvedField(ObjPtr<mirror::Class> klass, ObjPtr<mirror::ClassLoader> class_loader, uint32_t field_idx, bool is_static) { - ArtField* resolved = nullptr; - Thread* self = is_static ? Thread::Current() : nullptr; - const DexFile& dex_file = *dex_cache->GetDexFile(); - - resolved = is_static ? mirror::Class::FindStaticField(self, klass, dex_cache, field_idx) - : klass->FindInstanceField(dex_cache, field_idx); + ArtField* resolved = is_static ? klass->FindStaticField(dex_cache, field_idx) + : klass->FindInstanceField(dex_cache, field_idx); if (resolved == nullptr) { + const DexFile& dex_file = *dex_cache->GetDexFile(); const dex::FieldId& field_id = dex_file.GetFieldId(field_idx); const char* name = dex_file.GetFieldName(field_id); const char* type = dex_file.GetFieldTypeDescriptor(field_id); - resolved = is_static ? mirror::Class::FindStaticField(self, klass, name, type) + resolved = is_static ? klass->FindStaticField(name, type) : klass->FindInstanceField(name, type); } @@ -9359,8 +9348,7 @@ ArtField* ClassLinker::FindResolvedFieldJLS(ObjPtr<mirror::Class> klass, ObjPtr<mirror::DexCache> dex_cache, ObjPtr<mirror::ClassLoader> class_loader, uint32_t field_idx) { - Thread* self = Thread::Current(); - ArtField* resolved = mirror::Class::FindField(self, klass, dex_cache, field_idx); + ArtField* resolved = klass->FindField(dex_cache, field_idx); if (resolved != nullptr && hiddenapi::ShouldDenyAccessToMember(resolved, |