Regenerate the .oat file found in FindOatFile if it's out of date.
Change-Id: I285242c254d2622a7b92e7d7b5ffa38c1972633c
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 7c07f00..64d4025 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -625,12 +625,17 @@
const OatFile* ClassLinker::FindOatFile(const DexFile& dex_file) {
MutexLock mu(dex_lock_);
- // TODO: check if dex_file matches an OatDexFile location and checksum
const OatFile* oat_file = FindOatFile(OatFile::DexFilenameToOatFilename(dex_file.GetLocation()));
if (oat_file != NULL) {
- return oat_file;
+ const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file.GetLocation());
+ if (dex_file.GetHeader().checksum_ == oat_dex_file->GetDexFileChecksum()) {
+ return oat_file;
+ }
+ LOG(WARNING) << ".oat file " << oat_file->GetLocation()
+ << " is older than " << dex_file.GetLocation() << " --- regenerating";
+ // Fall through...
}
- // generate oat file if it wasn't found
+ // Generate oat file if it wasn't found or was obsolete.
oat_file = GenerateOatFile(dex_file.GetLocation());
if (oat_file == NULL) {
LOG(ERROR) << "Failed to generate oat file from dex file " << dex_file.GetLocation();