summaryrefslogtreecommitdiffstats
path: root/libart/src/main/java/dalvik
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2013-05-16 11:03:14 -0700
committerIan Rogers <irogers@google.com>2013-08-13 20:47:29 +0000
commit1e93f6737ef1a3540c8ce19c4fe3fa2efcdc1c78 (patch)
treee4bf4ba82e2089ec32e00f5fa3f951d8db0f916a /libart/src/main/java/dalvik
parent2450383af2b0e5197f580062106679245c15d786 (diff)
downloadlibcore-1e93f6737ef1a3540c8ce19c4fe3fa2efcdc1c78.zip
libcore-1e93f6737ef1a3540c8ce19c4fe3fa2efcdc1c78.tar.gz
libcore-1e93f6737ef1a3540c8ce19c4fe3fa2efcdc1c78.tar.bz2
Increase breadcrumbs for class lookup failures.
Dex files are loaded early and then queried against. This leads to IOExceptions for failed to load dex files being unavailable when a findClass is performed. Its useful to have the IOExceptions as then its possible to determine why a class wasn't found, for example, because the jar archive was empty. This change caches the IOExceptions that occur during the loading of dex files and then adds them to the suppressed exceptions reported when findClass fails. Change-Id: I31693400c503a113282f9d094ddfd84ebc3cf6dd (cherry picked from commit 04205541b4dda4c199a7fe72ab72eb0766a4207c)
Diffstat (limited to 'libart/src/main/java/dalvik')
-rw-r--r--libart/src/main/java/dalvik/system/DexPathList.java36
1 files changed, 25 insertions, 11 deletions
diff --git a/libart/src/main/java/dalvik/system/DexPathList.java b/libart/src/main/java/dalvik/system/DexPathList.java
index 5518c83..1d86a72 100644
--- a/libart/src/main/java/dalvik/system/DexPathList.java
+++ b/libart/src/main/java/dalvik/system/DexPathList.java
@@ -66,6 +66,11 @@ import static libcore.io.OsConstants.*;
private final File[] nativeLibraryDirectories;
/**
+ * Exceptions thrown during creation of the dexElements list.
+ */
+ private final IOException[] dexElementsSuppressedExceptions;
+
+ /**
* Constructs an instance.
*
* @param definingContext the context in which any as-yet unresolved
@@ -104,7 +109,15 @@ import static libcore.io.OsConstants.*;
}
this.definingContext = definingContext;
- this.dexElements = makeDexElements(splitDexPath(dexPath), optimizedDirectory);
+ ArrayList<IOException> suppressedExceptions = new ArrayList<IOException>();
+ this.dexElements = makeDexElements(splitDexPath(dexPath), optimizedDirectory,
+ suppressedExceptions);
+ if (suppressedExceptions.size() > 0) {
+ this.dexElementsSuppressedExceptions =
+ suppressedExceptions.toArray(new IOException[suppressedExceptions.size()]);
+ } else {
+ dexElementsSuppressedExceptions = null;
+ }
this.nativeLibraryDirectories = splitLibraryPath(libraryPath);
}
@@ -195,10 +208,9 @@ import static libcore.io.OsConstants.*;
* Makes an array of dex/resource path elements, one per element of
* the given array.
*/
- private static Element[] makeDexElements(ArrayList<File> files,
- File optimizedDirectory) {
+ private static Element[] makeDexElements(ArrayList<File> files, File optimizedDirectory,
+ ArrayList<IOException> suppressedExceptions) {
ArrayList<Element> elements = new ArrayList<Element>();
-
/*
* Open all files and load the (direct or contained) dex files
* up front.
@@ -221,14 +233,14 @@ import static libcore.io.OsConstants.*;
try {
dex = loadDexFile(file, optimizedDirectory);
- } catch (IOException ignored) {
+ } catch (IOException suppressed) {
/*
- * IOException might get thrown "legitimately" by
- * the DexFile constructor if the zip file turns
- * out to be resource-only (that is, no
- * classes.dex file in it). Safe to just ignore
- * the exception here, and let dex == null.
+ * IOException might get thrown "legitimately" by the DexFile constructor if the
+ * zip file turns out to be resource-only (that is, no classes.dex file in it).
+ * Let dex == null and hang on to the exception to add to the tea-leaves for
+ * when findClass returns null.
*/
+ suppressedExceptions.add(suppressed);
}
} else if (file.isDirectory()) {
// We support directories for looking up resources.
@@ -294,7 +306,9 @@ import static libcore.io.OsConstants.*;
}
}
}
-
+ if (dexElementsSuppressedExceptions != null) {
+ suppressed.addAll(Arrays.asList(dexElementsSuppressedExceptions));
+ }
return null;
}