[art] Add classpath check to DexFile.getDexOptNeeded
Extend DexFile.getDexOptNeeded to factor into the decision the
expected class loader context. If the context does not match oat
file assistant and dexoptanalyzer will advise kDex2OatFromScratch.
(cherry picked from commit baafa55aede7cc43a27d76bd88ccc02152123ecf)
Bug: 62269291
Test: m test-art-host
Merged-In: I3a8e9321fe602712fac3595b790168b271918f10
Change-Id: I3a8e9321fe602712fac3595b790168b271918f10
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index a7fe9b1..fb61228 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -1168,12 +1168,13 @@
const OatFile* file = GetFile();
if (file == nullptr) {
- return false;
+ // No oat file means we have nothing to verify.
+ return true;
}
- size_t dir_index = file->GetLocation().rfind('/');
+ size_t dir_index = oat_file_assistant_->dex_location_.rfind('/');
std::string classpath_dir = (dir_index != std::string::npos)
- ? file->GetLocation().substr(0, dir_index)
+ ? oat_file_assistant_->dex_location_.substr(0, dir_index)
: "";
if (!context->OpenDexFiles(oat_file_assistant_->isa_, classpath_dir)) {