diff options
| author | 2015-01-19 15:14:02 +0000 | |
|---|---|---|
| committer | 2015-01-19 15:14:02 +0000 | |
| commit | 17f50f8119f4a8bdec304cde527f68ddd0b3bc0a (patch) | |
| tree | 1727c50bb38f1600e66bf7b2cf2ec3ec1711c628 | |
| parent | 3e809794fe558d8a10851c0ac22a65a2c81fa315 (diff) | |
| parent | d8beca64e086a9c4a214c7dcb9b6e59c2c482173 (diff) | |
am d8beca64: Merge "Remove support for --classpath and make --runtime-init the default."
* commit 'd8beca64e086a9c4a214c7dcb9b6e59c2c482173':
  Remove support for --classpath and make --runtime-init the default.
| -rw-r--r-- | core/java/android/os/Process.java | 4 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteConnection.java | 93 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 48 | 
3 files changed, 20 insertions, 125 deletions
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 21a990421e59..4834f9727f26 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -614,9 +614,9 @@ public class Process {          synchronized(Process.class) {              ArrayList<String> argsForZygote = new ArrayList<String>(); -            // --runtime-init, --setuid=, --setgid=, +            // --runtime-args, --setuid=, --setgid=,              // and --setgroups= must go first -            argsForZygote.add("--runtime-init"); +            argsForZygote.add("--runtime-args");              argsForZygote.add("--setuid=" + uid);              argsForZygote.add("--setgid=" + gid);              if ((debugFlags & Zygote.DEBUG_ENABLE_JNI_LOGGING) != 0) { diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index 28cd79986cc3..7fac05b8cdce 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -191,7 +191,7 @@ class ZygoteConnection {                  rlimits = parsedArgs.rlimits.toArray(intArray2d);              } -            if (parsedArgs.runtimeInit && parsedArgs.invokeWith != null) { +            if (parsedArgs.invokeWith != null) {                  FileDescriptor[] pipeFds = Os.pipe2(O_CLOEXEC);                  childPipeFd = pipeFds[1];                  serverPipeFd = pipeFds[0]; @@ -303,20 +303,13 @@ class ZygoteConnection {       *   <li> --rlimit=r,c,m<i>tuple of values for setrlimit() call.       *    <code>r</code> is the resource, <code>c</code> and <code>m</code>       *    are the settings for current and max value.</i> -     *   <li> --classpath=<i>colon-separated classpath</i> indicates -     * that the specified class (which must b first non-flag argument) should -     * be loaded from jar files in the specified classpath. Incompatible with -     * --runtime-init -     *   <li> --runtime-init indicates that the remaining arg list should +     *   <li> --instruction-set=<i>instruction-set-string</i> which instruction set to use/emulate. +     *   <li> --nice-name=<i>nice name to appear in ps</i> +     *   <li> --runtime-args indicates that the remaining arg list should       * be handed off to com.android.internal.os.RuntimeInit, rather than -     * processed directly +     * processed directly.       * Android runtime startup (eg, Binder initialization) is also eschewed. -     *   <li> --nice-name=<i>nice name to appear in ps</i> -     *   <li> If <code>--runtime-init</code> is present: -     *      [--] <args for RuntimeInit > -     *   <li> If <code>--runtime-init</code> is absent: -     *      [--] <classname> [args...] -     *   <li> --instruction-set=<i>instruction-set-string</i> which instruction set to use/emulate. +     *   <li> [--] <args for RuntimeInit >       * </ul>       */      static class Arguments { @@ -344,12 +337,6 @@ class ZygoteConnection {          int targetSdkVersion;          boolean targetSdkVersionSpecified; -        /** from --classpath */ -        String classpath; - -        /** from --runtime-init */ -        boolean runtimeInit; -          /** from --nice-name */          String niceName; @@ -411,6 +398,8 @@ class ZygoteConnection {                  throws IllegalArgumentException {              int curArg = 0; +            boolean seenRuntimeArgs = true; +              for ( /* curArg */ ; curArg < args.length; curArg++) {                  String arg = args[curArg]; @@ -451,8 +440,8 @@ class ZygoteConnection {                      debugFlags |= Zygote.DEBUG_ENABLE_JNI_LOGGING;                  } else if (arg.equals("--enable-assert")) {                      debugFlags |= Zygote.DEBUG_ENABLE_ASSERT; -                } else if (arg.equals("--runtime-init")) { -                    runtimeInit = true; +                } else if (arg.equals("--runtime-args")) { +                    seenRuntimeArgs = true;                  } else if (arg.startsWith("--seinfo=")) {                      if (seInfoSpecified) {                          throw new IllegalArgumentException( @@ -497,17 +486,6 @@ class ZygoteConnection {                      }                      rlimits.add(rlimitTuple); -                } else if (arg.equals("-classpath")) { -                    if (classpath != null) { -                        throw new IllegalArgumentException( -                                "Duplicate arg specified"); -                    } -                    try { -                        classpath = args[++curArg]; -                    } catch (IndexOutOfBoundsException ex) { -                        throw new IllegalArgumentException( -                                "-classpath requires argument"); -                    }                  } else if (arg.startsWith("--setgroups=")) {                      if (gids != null) {                          throw new IllegalArgumentException( @@ -554,9 +532,8 @@ class ZygoteConnection {                  }              } -            if (runtimeInit && classpath != null) { -                throw new IllegalArgumentException( -                        "--runtime-init and -classpath are incompatible"); +            if (!seenRuntimeArgs) { +                throw new IllegalArgumentException("Unexpected argument : " + args[curArg]);              }              remainingArgs = new String[args.length - curArg]; @@ -878,47 +855,13 @@ class ZygoteConnection {              Process.setArgV0(parsedArgs.niceName);          } -        if (parsedArgs.runtimeInit) { -            if (parsedArgs.invokeWith != null) { -                WrapperInit.execApplication(parsedArgs.invokeWith, -                        parsedArgs.niceName, parsedArgs.targetSdkVersion, -                        pipeFd, parsedArgs.remainingArgs); -            } else { -                RuntimeInit.zygoteInit(parsedArgs.targetSdkVersion, -                        parsedArgs.remainingArgs, null /* classLoader */); -            } +        if (parsedArgs.invokeWith != null) { +            WrapperInit.execApplication(parsedArgs.invokeWith, +                    parsedArgs.niceName, parsedArgs.targetSdkVersion, +                    pipeFd, parsedArgs.remainingArgs);          } else { -            String className; -            try { -                className = parsedArgs.remainingArgs[0]; -            } catch (ArrayIndexOutOfBoundsException ex) { -                logAndPrintError(newStderr, -                        "Missing required class name argument", null); -                return; -            } - -            String[] mainArgs = new String[parsedArgs.remainingArgs.length - 1]; -            System.arraycopy(parsedArgs.remainingArgs, 1, -                    mainArgs, 0, mainArgs.length); - -            if (parsedArgs.invokeWith != null) { -                WrapperInit.execStandalone(parsedArgs.invokeWith, -                        parsedArgs.classpath, className, mainArgs); -            } else { -                ClassLoader cloader; -                if (parsedArgs.classpath != null) { -                    cloader = new PathClassLoader(parsedArgs.classpath, -                            ClassLoader.getSystemClassLoader()); -                } else { -                    cloader = ClassLoader.getSystemClassLoader(); -                } - -                try { -                    ZygoteInit.invokeStaticMain(cloader, className, mainArgs); -                } catch (RuntimeException ex) { -                    logAndPrintError(newStderr, "Error starting.", ex); -                } -            } +            RuntimeInit.zygoteInit(parsedArgs.targetSdkVersion, +                    parsedArgs.remainingArgs, null /* classLoader */);          }      } diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index e6f3c0ae6dd7..b8082e1ad953 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -103,54 +103,6 @@ public class ZygoteInit {      private static final boolean PRELOAD_RESOURCES = true;      /** -     * Invokes a static "main(argv[]) method on class "className". -     * Converts various failing exceptions into RuntimeExceptions, with -     * the assumption that they will then cause the VM instance to exit. -     * -     * @param loader class loader to use -     * @param className Fully-qualified class name -     * @param argv Argument vector for main() -     */ -    static void invokeStaticMain(ClassLoader loader, -            String className, String[] argv) -            throws ZygoteInit.MethodAndArgsCaller { -        Class<?> cl; - -        try { -            cl = loader.loadClass(className); -        } catch (ClassNotFoundException ex) { -            throw new RuntimeException( -                    "Missing class when invoking static main " + className, -                    ex); -        } - -        Method m; -        try { -            m = cl.getMethod("main", new Class[] { String[].class }); -        } catch (NoSuchMethodException ex) { -            throw new RuntimeException( -                    "Missing static main on " + className, ex); -        } catch (SecurityException ex) { -            throw new RuntimeException( -                    "Problem getting static main on " + className, ex); -        } - -        int modifiers = m.getModifiers(); -        if (! (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers))) { -            throw new RuntimeException( -                    "Main method is not public and static on " + className); -        } - -        /* -         * This throw gets caught in ZygoteInit.main(), which responds -         * by invoking the exception's run() method. This arrangement -         * clears up all the stack frames that were required in setting -         * up the process. -         */ -        throw new ZygoteInit.MethodAndArgsCaller(m, argv); -    } - -    /**       * Registers a server socket for zygote command connections       *       * @throws RuntimeException when open fails  |