diff options
| author | 2015-09-01 21:00:15 +0000 | |
|---|---|---|
| committer | 2015-09-01 21:00:15 +0000 | |
| commit | 8056e4132416265196c9f0f3cc0e86bceeb7d907 (patch) | |
| tree | 2bf3830af35d7814f83358e49e50878a69d955f3 | |
| parent | f31cced13419f3fbf473d91a4688c307b5a32fd9 (diff) | |
| parent | 346296bd7d28fa79509605f30a222eb85d6bbb5d (diff) | |
Merge "Reset class loader after updating instrumentation paths"
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 9 | ||||
| -rw-r--r-- | core/java/android/app/LoadedApk.java | 7 |
2 files changed, 15 insertions, 1 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 412e3cde902c..e15ba742b8b6 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -4718,7 +4718,13 @@ public final class ActivityThread { mInstrumentedSplitAppDirs = data.info.getSplitAppDirs(); mInstrumentedLibDir = data.info.getLibDir(); - ApplicationInfo instrApp = new ApplicationInfo(); + // The app context's info was created against this thread, but + // the class loader may have already been loaded and cached with + // outdated paths. Clear it so we can load it again using the + // instrumentation paths. + data.info.clearClassLoader(); + + final ApplicationInfo instrApp = new ApplicationInfo(); instrApp.packageName = ii.packageName; instrApp.sourceDir = ii.sourceDir; instrApp.publicSourceDir = ii.publicSourceDir; @@ -4731,6 +4737,7 @@ public final class ActivityThread { ContextImpl instrContext = ContextImpl.createAppContext(this, pi); try { + java.lang.ClassLoader cl = instrContext.getClassLoader(); mInstrumentation = (Instrumentation) cl.loadClass(data.instrumentationName.getClassName()).newInstance(); diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index c2bf28a931c8..3b1c60b1501f 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -255,6 +255,13 @@ public final class LoadedApk { return ai.sharedLibraryFiles; } + /** @hide */ + public void clearClassLoader() { + synchronized (this) { + mClassLoader = null; + } + } + public ClassLoader getClassLoader() { synchronized (this) { if (mClassLoader != null) { |