Load classes for boot image extension.
Previously we actually failed to load and initialize classes
for boot image extensions. Though some classes may have been
resolved by other code paths, extension art files did not
contain the intended classes. This CL fixes that and some
other bugs that were exposed by this class initialization.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I63a1970f7ff45dc37b14ebd24c5a68f3edacd6ef
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c87d0f7..0445584 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -5361,14 +5361,15 @@
return false;
}
}
- // If we are a class we need to initialize all interfaces with default methods when we are
- // initialized. Check all of them.
- if (!klass->IsInterface()) {
- size_t num_interfaces = klass->GetIfTableCount();
- for (size_t i = 0; i < num_interfaces; i++) {
- ObjPtr<mirror::Class> iface = klass->GetIfTable()->GetInterface(i);
- if (iface->HasDefaultMethods() &&
- !CanWeInitializeClass(iface, can_init_statics, can_init_parents)) {
+ }
+ // If we are a class we need to initialize all interfaces with default methods when we are
+ // initialized. Check all of them.
+ if (!klass->IsInterface()) {
+ size_t num_interfaces = klass->GetIfTableCount();
+ for (size_t i = 0; i < num_interfaces; i++) {
+ ObjPtr<mirror::Class> iface = klass->GetIfTable()->GetInterface(i);
+ if (iface->HasDefaultMethods() && !iface->IsInitialized()) {
+ if (!can_init_parents || !CanWeInitializeClass(iface, can_init_statics, can_init_parents)) {
return false;
}
}
@@ -5378,10 +5379,10 @@
return true;
}
ObjPtr<mirror::Class> super_class = klass->GetSuperClass();
- if (!can_init_parents && !super_class->IsInitialized()) {
- return false;
+ if (super_class->IsInitialized()) {
+ return true;
}
- return CanWeInitializeClass(super_class, can_init_statics, can_init_parents);
+ return can_init_parents && CanWeInitializeClass(super_class, can_init_statics, can_init_parents);
}
bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass,