summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dalvik/src/main/java/dalvik/system/DexFile.java12
-rw-r--r--dalvik/src/main/java/dalvik/system/DexPathList.java5
2 files changed, 17 insertions, 0 deletions
diff --git a/dalvik/src/main/java/dalvik/system/DexFile.java b/dalvik/src/main/java/dalvik/system/DexFile.java
index 8d32931afc..48e34c85da 100644
--- a/dalvik/src/main/java/dalvik/system/DexFile.java
+++ b/dalvik/src/main/java/dalvik/system/DexFile.java
@@ -389,6 +389,18 @@ public final class DexFile {
int[] starts, int[] ends);
/*
+ * Initiates background verification of this DexFile. This is a sepearate down-call
+ * from openDexFile and openInMemoryDexFiles because it requires the class loader's
+ * DexPathList to have been initialized for its classes to be resolvable by ART.
+ * DexPathList will open the dex files first, finalize `dexElements` and then call this.
+ */
+ /*package*/ void verifyInBackground(ClassLoader classLoader) {
+ verifyInBackgroundNative(mCookie, classLoader);
+ }
+
+ private static native void verifyInBackgroundNative(Object mCookie, ClassLoader classLoader);
+
+ /*
* Returns true if the dex file is backed by a valid oat file.
*/
@UnsupportedAppUsage
diff --git a/dalvik/src/main/java/dalvik/system/DexPathList.java b/dalvik/src/main/java/dalvik/system/DexPathList.java
index fc57dc0a25..5efefddc78 100644
--- a/dalvik/src/main/java/dalvik/system/DexPathList.java
+++ b/dalvik/src/main/java/dalvik/system/DexPathList.java
@@ -268,6 +268,11 @@ public final class DexPathList {
Element[] null_elements = null;
DexFile dex = new DexFile(dexFiles);
dexElements = new Element[] { new Element(dex) };
+ // Spawn background thread to verify all classes and cache verification results.
+ // Must be called *after* `dexElements` has been initialized for ART to find
+ // its classes (the field is hardcoded in ART and dex files iterated over in
+ // the order of the array).
+ dex.verifyInBackground(definingContext);
} catch (IOException suppressed) {
System.logE("Unable to load dex files", suppressed);
suppressedExceptions.add(suppressed);