Merge "Set system server's class loader for wrap.system_server"
am: 8d2d6bfa12
Change-Id: Iba4af152c9f29ad6e8c9bb1b0a1047e96d287c6b
This commit is contained in:
@@ -139,6 +139,21 @@ public class WrapperInit {
|
||||
Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from wrapper");
|
||||
}
|
||||
|
||||
RuntimeInit.applicationInit(targetSdkVersion, argv, null);
|
||||
// Check whether the first argument is a "-cp" in argv, and assume the next argument is the
|
||||
// classpath. If found, create a PathClassLoader and use it for applicationInit.
|
||||
ClassLoader classLoader = null;
|
||||
if (argv != null && argv.length > 2 && argv[0].equals("-cp")) {
|
||||
classLoader = ZygoteInit.createPathClassLoader(argv[1], targetSdkVersion);
|
||||
|
||||
// Install this classloader as the context classloader, too.
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
|
||||
// Remove the classpath from the arguments.
|
||||
String removedArgs[] = new String[argv.length - 2];
|
||||
System.arraycopy(argv, 2, removedArgs, 0, argv.length - 2);
|
||||
argv = removedArgs;
|
||||
}
|
||||
|
||||
RuntimeInit.applicationInit(targetSdkVersion, argv, classLoader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,7 +452,8 @@ public class ZygoteInit {
|
||||
String[] amendedArgs = new String[args.length + 2];
|
||||
amendedArgs[0] = "-cp";
|
||||
amendedArgs[1] = systemServerClasspath;
|
||||
System.arraycopy(parsedArgs.remainingArgs, 0, amendedArgs, 2, parsedArgs.remainingArgs.length);
|
||||
System.arraycopy(args, 0, amendedArgs, 2, args.length);
|
||||
args = amendedArgs;
|
||||
}
|
||||
|
||||
WrapperInit.execApplication(parsedArgs.invokeWith,
|
||||
@@ -461,8 +462,7 @@ public class ZygoteInit {
|
||||
} else {
|
||||
ClassLoader cl = null;
|
||||
if (systemServerClasspath != null) {
|
||||
cl = createSystemServerClassLoader(systemServerClasspath,
|
||||
parsedArgs.targetSdkVersion);
|
||||
cl = createPathClassLoader(systemServerClasspath, parsedArgs.targetSdkVersion);
|
||||
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
}
|
||||
@@ -477,15 +477,14 @@ public class ZygoteInit {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Creates a PathClassLoader for the given class path that is associated with a shared
|
||||
* namespace, i.e., this classloader can access platform-private native libraries. The
|
||||
* classloader will use java.library.path as the native library path.
|
||||
*/
|
||||
private static PathClassLoader createSystemServerClassLoader(String systemServerClasspath,
|
||||
int targetSdkVersion) {
|
||||
static PathClassLoader createPathClassLoader(String classPath, int targetSdkVersion) {
|
||||
String libraryPath = System.getProperty("java.library.path");
|
||||
|
||||
return PathClassLoaderFactory.createClassLoader(systemServerClasspath,
|
||||
return PathClassLoaderFactory.createClassLoader(classPath,
|
||||
libraryPath,
|
||||
libraryPath,
|
||||
ClassLoader.getSystemClassLoader(),
|
||||
|
||||
Reference in New Issue
Block a user