Create linker namespace for the system server classloader

Bug: http://b/27702070
Change-Id: I12c9448e877202937cf558de75042bcb46f6a933
(cherry picked from commit eb5866d4b0)
This commit is contained in:
Dimitry Ivanov
2016-04-20 16:02:00 -07:00
parent b1ef62bb38
commit 89dad3360e

View File

@@ -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.