summaryrefslogtreecommitdiff
path: root/runtime/native/java_lang_VMClassLoader.cc
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2014-07-24 15:35:50 -0700
committer Andreas Gampe <agampe@google.com> 2014-07-24 15:35:50 -0700
commitcb8f9e8a2941971c049b26745ea713c859342d9b (patch)
treec1600a19f134f45ecb8f4feea8c543df751f348f /runtime/native/java_lang_VMClassLoader.cc
parent80b3f96ec1e408f34b8e7b76b14774794fa1abd8 (diff)
ART: Account for multidex location strings in VMClassLoader
To look up resources, look in the unadorned location. Bug: 16530747 Change-Id: Ia97e39366444f6666a78ade7298d3c22b4b79f8a
Diffstat (limited to 'runtime/native/java_lang_VMClassLoader.cc')
-rw-r--r--runtime/native/java_lang_VMClassLoader.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc
index f2b8a03c13..fefddae761 100644
--- a/runtime/native/java_lang_VMClassLoader.cc
+++ b/runtime/native/java_lang_VMClassLoader.cc
@@ -62,25 +62,28 @@ static jint VMClassLoader_getBootClassPathSize(JNIEnv*, jclass) {
*/
static jstring VMClassLoader_getBootClassPathResource(JNIEnv* env, jclass, jstring javaName, jint index) {
ScopedUtfChars name(env, javaName);
- if (name.c_str() == NULL) {
- return NULL;
+ if (name.c_str() == nullptr) {
+ return nullptr;
}
const std::vector<const DexFile*>& path = Runtime::Current()->GetClassLinker()->GetBootClassPath();
if (index < 0 || size_t(index) >= path.size()) {
- return NULL;
+ return nullptr;
}
const DexFile* dex_file = path[index];
- const std::string& location(dex_file->GetLocation());
+
+ // For multidex locations, e.g., x.jar:classes2.dex, we want to look into x.jar.
+ const std::string& location(dex_file->GetBaseLocation());
+
std::string error_msg;
std::unique_ptr<ZipArchive> zip_archive(ZipArchive::Open(location.c_str(), &error_msg));
if (zip_archive.get() == nullptr) {
LOG(WARNING) << "Failed to open zip archive '" << location << "': " << error_msg;
- return NULL;
+ return nullptr;
}
std::unique_ptr<ZipEntry> zip_entry(zip_archive->Find(name.c_str(), &error_msg));
- if (zip_entry.get() == NULL) {
- return NULL;
+ if (zip_entry.get() == nullptr) {
+ return nullptr;
}
std::string url;