Fix VerifyClassUsingOatFile to check preverified image classes
We now bail out in two cases: we're verifying an application class or we're
verifying a boot classpath class while compiling boot classpath classes.
Change-Id: I0b8c776c032612a24799d72468dcf26280a9ab8d
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index e35b95c..6c1db70 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2324,12 +2324,25 @@
bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class* klass,
mirror::Class::Status& oat_file_class_status) {
- if (!Runtime::Current()->IsStarted()) {
- return false;
+
+ // If we're compiling, we can only verify the class using the oat file if
+ // we are not compiling the image or if the class we're verifying is not part of
+ // the app. In other words, we will only check for preverification of bootclasspath
+ // classes.
+ if (Runtime::Current()->IsCompiler()) {
+ // Are we compiling the bootclasspath?
+ if (!Runtime::Current()->UseCompileTimeClassPath()) {
+ return false;
+ }
+ // We are compiling an app (not the image).
+
+ // Is this an app class? (I.e. not a bootclasspath class)
+ if (klass->GetClassLoader() != NULL) {
+ return false;
+ }
}
- if (Runtime::Current()->UseCompileTimeClassPath()) {
- return false;
- }
+
+
const OatFile* oat_file = FindOpenedOatFileForDexFile(dex_file);
CHECK(oat_file != NULL) << dex_file.GetLocation() << " " << PrettyClass(klass);
const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file.GetLocation());
@@ -2344,7 +2357,7 @@
oat_file_class_status = oat_class->GetStatus();
if (oat_file_class_status == mirror::Class::kStatusVerified ||
oat_file_class_status == mirror::Class::kStatusInitialized) {
- return true;
+ return true;
}
if (oat_file_class_status == mirror::Class::kStatusRetryVerificationAtRuntime) {
// Compile time verification failed with a soft error. Compile time verification can fail