Merge "Set system server's class loader for wrap.system_server"
This commit is contained in:
@@ -139,6 +139,21 @@ public class WrapperInit {
|
|||||||
Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from wrapper");
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -449,7 +449,8 @@ public class ZygoteInit {
|
|||||||
String[] amendedArgs = new String[args.length + 2];
|
String[] amendedArgs = new String[args.length + 2];
|
||||||
amendedArgs[0] = "-cp";
|
amendedArgs[0] = "-cp";
|
||||||
amendedArgs[1] = systemServerClasspath;
|
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,
|
WrapperInit.execApplication(parsedArgs.invokeWith,
|
||||||
@@ -458,8 +459,7 @@ public class ZygoteInit {
|
|||||||
} else {
|
} else {
|
||||||
ClassLoader cl = null;
|
ClassLoader cl = null;
|
||||||
if (systemServerClasspath != null) {
|
if (systemServerClasspath != null) {
|
||||||
cl = createSystemServerClassLoader(systemServerClasspath,
|
cl = createPathClassLoader(systemServerClasspath, parsedArgs.targetSdkVersion);
|
||||||
parsedArgs.targetSdkVersion);
|
|
||||||
|
|
||||||
Thread.currentThread().setContextClassLoader(cl);
|
Thread.currentThread().setContextClassLoader(cl);
|
||||||
}
|
}
|
||||||
@@ -474,15 +474,14 @@ public class ZygoteInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a PathClassLoader for the system server. It also creates
|
* Creates a PathClassLoader for the given class path that is associated with a shared
|
||||||
* a shared namespace associated with the classloader to let it access
|
* namespace, i.e., this classloader can access platform-private native libraries. The
|
||||||
* platform-private native libraries.
|
* classloader will use java.library.path as the native library path.
|
||||||
*/
|
*/
|
||||||
private static PathClassLoader createSystemServerClassLoader(String systemServerClasspath,
|
static PathClassLoader createPathClassLoader(String classPath, int targetSdkVersion) {
|
||||||
int targetSdkVersion) {
|
|
||||||
String libraryPath = System.getProperty("java.library.path");
|
String libraryPath = System.getProperty("java.library.path");
|
||||||
|
|
||||||
return PathClassLoaderFactory.createClassLoader(systemServerClasspath,
|
return PathClassLoaderFactory.createClassLoader(classPath,
|
||||||
libraryPath,
|
libraryPath,
|
||||||
libraryPath,
|
libraryPath,
|
||||||
ClassLoader.getSystemClassLoader(),
|
ClassLoader.getSystemClassLoader(),
|
||||||
|
|||||||
Reference in New Issue
Block a user