diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 78b5d61d3f1a3..a4794a3e8291f 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -475,7 +475,9 @@ public class ZygoteInit { } else { ClassLoader cl = null; if (systemServerClasspath != null) { - cl = new PathClassLoader(systemServerClasspath, ClassLoader.getSystemClassLoader()); + cl = createSystemServerClassLoader(systemServerClasspath, + parsedArgs.targetSdkVersion); + Thread.currentThread().setContextClassLoader(cl); } @@ -488,6 +490,23 @@ public class ZygoteInit { /* should never reach here */ } + /** + * Creates a PathClassLoader for the system server. It also creates + * a shared namespace associated with the classloader to let it access + * platform-private native libraries. + */ + private static PathClassLoader createSystemServerClassLoader(String systemServerClasspath, + int targetSdkVersion) { + String librarySearchPath = System.getProperty("java.library.path"); + + return PathClassLoaderFactory.createClassLoader(systemServerClasspath, + librarySearchPath, + null /* libraryPermittedPath */, + ClassLoader.getSystemClassLoader(), + targetSdkVersion, + true /* isNamespaceShared */); + } + /** * Performs dex-opt on the elements of {@code classPath}, if needed. We * choose the instruction set of the current runtime.