summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Brazdil <dbrazdil@google.com>2019-04-02 19:20:16 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-04-02 19:20:16 +0000
commitb9d77e102b8418cd70b7fc9466ea52057e17c980 (patch)
treeb5b185710570f192351ade2d650575e5830054ae
parent4e17e5f491c811e3b5504bc4c670711c6368ebc9 (diff)
parent2fb58aef4e344044bb3355947677b57cf8c303d8 (diff)
Merge "Provide class loader context to DexFile.verifyInBackground"
-rw-r--r--dalvik/src/main/java/dalvik/system/DexFile.java10
-rw-r--r--dalvik/src/main/java/dalvik/system/DexPathList.java9
2 files changed, 14 insertions, 5 deletions
diff --git a/dalvik/src/main/java/dalvik/system/DexFile.java b/dalvik/src/main/java/dalvik/system/DexFile.java
index 48e34c85da..2a81be1064 100644
--- a/dalvik/src/main/java/dalvik/system/DexFile.java
+++ b/dalvik/src/main/java/dalvik/system/DexFile.java
@@ -394,11 +394,15 @@ public final class DexFile {
* 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);
+ /*package*/ void verifyInBackground(ClassLoader classLoader, String classLoaderContext) {
+ verifyInBackgroundNative(mCookie, classLoader, classLoaderContext);
}
- private static native void verifyInBackgroundNative(Object mCookie, ClassLoader classLoader);
+ private static native void verifyInBackgroundNative(Object mCookie, ClassLoader classLoader,
+ String classLoaderContext);
+
+ /*package*/ static native String getClassLoaderContext(ClassLoader classLoader,
+ DexPathList.Element[] elements);
/*
* Returns true if the dex file is backed by a valid oat file.
diff --git a/dalvik/src/main/java/dalvik/system/DexPathList.java b/dalvik/src/main/java/dalvik/system/DexPathList.java
index 5efefddc78..227231a7d2 100644
--- a/dalvik/src/main/java/dalvik/system/DexPathList.java
+++ b/dalvik/src/main/java/dalvik/system/DexPathList.java
@@ -267,12 +267,17 @@ public final class DexPathList {
try {
Element[] null_elements = null;
DexFile dex = new DexFile(dexFiles);
+ // Capture class loader context from *before* `dexElements` is set (see comment below).
+ String classLoaderContext = DexFile.getClassLoaderContext(definingContext,
+ null_elements);
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);
+ // the order of the array), but with class loader context from *before*
+ // `dexElements` was set because that is what it will be compared against next
+ // time the same bytecode is loaded.
+ dex.verifyInBackground(definingContext, classLoaderContext);
} catch (IOException suppressed) {
System.logE("Unable to load dex files", suppressed);
suppressedExceptions.add(suppressed);