diff options
-rw-r--r-- | dalvik/src/main/java/dalvik/system/DexFile.java | 10 | ||||
-rw-r--r-- | dalvik/src/main/java/dalvik/system/DexPathList.java | 9 |
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); |