Clean up some logic skipping ValidateSuperClassDescriptors.
Addressed some comments in:
https://android-review.googlesource.com/#/c/434206/
Bug: 63456114
Test: mm test-art-host
Change-Id: I8c0e7bda667e8b12fbf14652f65c620c7e253360
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 1219f6f..775651b 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4860,11 +4860,16 @@
return WaitForInitializeClass(klass, self, lock);
}
+ // Try to get the oat class's status for this class if the oat file is present. The compiler
+ // tries to validate superclass descriptors, and writes the result into the oat file.
+ // Runtime correctness is guaranteed by classpath checks done on loading. If the classpath
+ // is different at runtime than it was at compile time, the oat file is rejected. So if the
+ // oat file is present, the classpaths must match, and the runtime time check can be skipped.
bool has_oat_class = false;
- const OatFile::OatClass oat_class =
- (Runtime::Current()->IsStarted() && !Runtime::Current()->IsAotCompiler())
- ? OatFile::FindOatClass(klass->GetDexFile(), klass->GetDexClassDefIndex(), &has_oat_class)
- : OatFile::OatClass::Invalid();
+ const Runtime* runtime = Runtime::Current();
+ const OatFile::OatClass oat_class = (runtime->IsStarted() && !runtime->IsAotCompiler())
+ ? OatFile::FindOatClass(klass->GetDexFile(), klass->GetDexClassDefIndex(), &has_oat_class)
+ : OatFile::OatClass::Invalid();
if (oat_class.GetStatus() < mirror::Class::kStatusSuperclassValidated &&
!ValidateSuperClassDescriptors(klass)) {
mirror::Class::SetStatus(klass, mirror::Class::kStatusErrorResolved, self);