From cb8f9e8a2941971c049b26745ea713c859342d9b Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Thu, 24 Jul 2014 15:35:50 -0700 Subject: ART: Account for multidex location strings in VMClassLoader To look up resources, look in the unadorned location. Bug: 16530747 Change-Id: Ia97e39366444f6666a78ade7298d3c22b4b79f8a --- runtime/native/java_lang_VMClassLoader.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'runtime/native/java_lang_VMClassLoader.cc') 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& 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 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 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; -- cgit v1.2.3-59-g8ed1b