Revert "Use real locations when opening dex files from the context"
This reverts commit 821a2595e2438554424879d6cb3594810ca8e636.
Reason for revert: Oat file assistant logic was updated to not
use realpaths anymore. So this is no longer needed.
Test: m test-art-host-gtest
Change-Id: Ia63a50f60b82ec3e20606d0be852607c9d2eb26e
diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc
index 38f59ef..b62764f 100644
--- a/runtime/class_loader_context.cc
+++ b/runtime/class_loader_context.cc
@@ -16,9 +16,6 @@
#include "class_loader_context.h"
-#include <stdlib.h>
-
-#include "android-base/file.h"
#include "art_field-inl.h"
#include "base/dchecked_vector.h"
#include "base/stl_util.h"
@@ -210,19 +207,9 @@
size_t opened_dex_files_index = info.opened_dex_files.size();
for (const std::string& cp_elem : info.classpath) {
// If path is relative, append it to the provided base directory.
- std::string raw_location = cp_elem;
- if (raw_location[0] != '/' && !classpath_dir.empty()) {
- raw_location = classpath_dir + '/' + raw_location;
- }
-
- std::string location; // the real location of the class path element.
-
- if (!android::base::Realpath(raw_location, &location)) {
- // If we can't get the realpath of the location there might be something wrong with the
- // classpath (maybe the file was deleted).
- // Do not continue in this case and return false.
- PLOG(WARNING) << "Could not get the realpath of dex location " << raw_location;
- return false;
+ std::string location = cp_elem;
+ if (location[0] != '/' && !classpath_dir.empty()) {
+ location = classpath_dir + '/' + location;
}
std::string error_msg;
@@ -728,15 +715,20 @@
dex_name = info.classpath[k];
expected_dex_name = OatFile::ResolveRelativeEncodedDexLocation(
info.classpath[k].c_str(), expected_info.classpath[k]);
- } else {
+ } else if (is_expected_dex_name_absolute) {
// The runtime name is relative but the compiled name is absolute.
// There is no expected use case that would end up here as dex files are always loaded
// with their absolute location. However, be tolerant and do the best effort (in case
// there are unexpected new use case...).
- DCHECK(is_expected_dex_name_absolute);
dex_name = OatFile::ResolveRelativeEncodedDexLocation(
expected_info.classpath[k].c_str(), info.classpath[k]);
expected_dex_name = expected_info.classpath[k];
+ } else {
+ // Both locations are relative. In this case there's not much we can be sure about
+ // except that the names are the same. The checksum will ensure that the files are
+ // are same. This should not happen outside testing and manual invocations.
+ dex_name = info.classpath[k];
+ expected_dex_name = expected_info.classpath[k];
}
// Compare the locations.