Loading core/java/com/android/internal/os/WrapperInit.java +16 −1 Original line number Diff line number Diff line Loading @@ -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); } } core/java/com/android/internal/os/ZygoteInit.java +8 −9 Original line number Diff line number Diff line Loading @@ -449,7 +449,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, Loading @@ -458,8 +459,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); } Loading @@ -474,15 +474,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(), Loading Loading
core/java/com/android/internal/os/WrapperInit.java +16 −1 Original line number Diff line number Diff line Loading @@ -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); } }
core/java/com/android/internal/os/ZygoteInit.java +8 −9 Original line number Diff line number Diff line Loading @@ -449,7 +449,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, Loading @@ -458,8 +459,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); } Loading @@ -474,15 +474,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(), Loading