user build support for art (2 of 3)
Change-Id: I4696fee58e43db48540e2442c4235fc4bb02d9e3
diff --git a/src/dalvik_system_DexFile.cc b/src/dalvik_system_DexFile.cc
index 713639f..f6568a7 100644
--- a/src/dalvik_system_DexFile.cc
+++ b/src/dalvik_system_DexFile.cc
@@ -185,13 +185,18 @@
}
}
- uint32_t location_checksum;
- if (!DexFile::GetChecksum(filename.c_str(), location_checksum)) {
- return JNI_TRUE;
+ // If we have an oat file next to the dex file, assume up-to-date.
+ // A user build looks like this, and it will have no classes.dex in
+ // the input for checksum validation.
+ std::string oat_filename(OatFile::DexFilenameToOatFilename(filename.c_str()));
+ const OatFile* oat_file = class_linker->FindOatFileFromOatLocation(oat_filename);
+ if (oat_file != NULL && oat_file->GetOatDexFile(filename.c_str()) != NULL) {
+ return JNI_FALSE;
}
- std::string oat_filename(OatFile::DexFilenameToOatFilename(filename.c_str()));
- const OatFile* oat_file(class_linker->FindOatFileFromOatLocation(oat_filename));
+ // Check if we have an oat file in the cache
+ std::string cache_location(GetArtCacheFilenameOrDie(oat_filename));
+ oat_file = class_linker->FindOatFileFromOatLocation(cache_location);
if (oat_file == NULL) {
return JNI_TRUE;
}
@@ -201,6 +206,11 @@
return JNI_TRUE;
}
+ uint32_t location_checksum;
+ if (!DexFile::GetChecksum(filename.c_str(), location_checksum)) {
+ return JNI_TRUE;
+ }
+
if (location_checksum != oat_dex_file->GetDexFileLocationChecksum()) {
return JNI_TRUE;
}