From 8d31bbd3d6536de12bc20e3d29cfe03fe848f9da Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Sun, 13 Oct 2013 10:44:14 -0700 Subject: Throw IOException at source of failing to open a dex file. Before is: java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) Suppressed: java.lang.ClassNotFoundException: GCBench at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 1 more Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found ... 5 more And after is: java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) Suppressed: java.io.IOException: Zip archive '/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar' doesn't contain classes.dex at dalvik.system.DexFile.openDexFile(Native Method) at dalvik.system.DexFile.(DexFile.java:80) at dalvik.system.DexFile.(DexFile.java:59) at dalvik.system.DexPathList.loadDexFile(DexPathList.java:268) at dalvik.system.DexPathList.makeDexElements(DexPathList.java:235) at dalvik.system.DexPathList.(DexPathList.java:113) at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:48) at dalvik.system.PathClassLoader.(PathClassLoader.java:38) at java.lang.ClassLoader.createSystemClassLoader(ClassLoader.java:128) at java.lang.ClassLoader.access$000(ClassLoader.java:65) at java.lang.ClassLoader$SystemClassLoader.(ClassLoader.java:81) at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:137) Suppressed: java.lang.ClassNotFoundException: GCBench at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 1 more Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found ... 5 more Also, move dex file verifier messages out of logs. In the process the ClassLinker::dex_lock_ needed tidying to cover a smaller scope. Bug 11301553. Change-Id: I80058652e11e7ea63457cc01a0cb48afe1c15543 --- runtime/oat_file.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'runtime/oat_file.h') diff --git a/runtime/oat_file.h b/runtime/oat_file.h index 270976f..af14760 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -45,18 +45,20 @@ class OatFile { static OatFile* Open(const std::string& filename, const std::string& location, byte* requested_base, - bool executable); + bool executable, + std::string* error_msg); // Open an oat file from an already opened File. // Does not use dlopen underneath so cannot be used for runtime use // where relocations may be required. Currently used from // ImageWriter which wants to open a writable version from an existing // file descriptor for patching. - static OatFile* OpenWritable(File* file, const std::string& location); + static OatFile* OpenWritable(File* file, const std::string& location, std::string* error_msg); // Open an oat file backed by a std::vector with the given location. static OatFile* OpenMemory(std::vector& oat_contents, - const std::string& location); + const std::string& location, + std::string* error_msg); ~OatFile(); @@ -167,7 +169,7 @@ class OatFile { class OatDexFile { public: // Opens the DexFile referred to by this OatDexFile from within the containing OatFile. - const DexFile* OpenDexFile() const; + const DexFile* OpenDexFile(std::string* error_msg) const; // Returns the size of the DexFile refered to by this OatDexFile. size_t FileSize() const; @@ -204,10 +206,10 @@ class OatFile { DISALLOW_COPY_AND_ASSIGN(OatDexFile); }; - const OatDexFile* GetOatDexFile(const std::string& dex_location, + const OatDexFile* GetOatDexFile(const char* dex_location, const uint32_t* const dex_location_checksum, - bool exception_if_not_found = true) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + bool exception_if_not_found = true) const; + std::vector GetOatDexFiles() const; size_t Size() const { @@ -219,18 +221,21 @@ class OatFile { static OatFile* OpenDlopen(const std::string& elf_filename, const std::string& location, - byte* requested_base); + byte* requested_base, + std::string* error_msg); static OatFile* OpenElfFile(File* file, const std::string& location, byte* requested_base, bool writable, - bool executable); + bool executable, + std::string* error_msg); explicit OatFile(const std::string& filename); - bool Dlopen(const std::string& elf_filename, byte* requested_base); - bool ElfFileOpen(File* file, byte* requested_base, bool writable, bool executable); - bool Setup(); + bool Dlopen(const std::string& elf_filename, byte* requested_base, std::string* error_msg); + bool ElfFileOpen(File* file, byte* requested_base, bool writable, bool executable, + std::string* error_msg); + bool Setup(std::string* error_msg); const byte* Begin() const; const byte* End() const; -- cgit v1.1