Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8244010

Simplify usages of ProcessTools.createJavaProcessBuilder in our tests

    XMLWordPrintable

Details

    • gc
    • b21

    Backports

      Description

        There are a many places where arguments are converted and passed back and forth in String[] and Collections.

        For example:
          ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                  argsList.toArray(new String[argsList.size()]));

        If we add an overload the createJavaProcessBuilder, that takes a Collection<String> as an argument, then we can write the code above as:
           ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(argsList);

        Other places temporarily put the flags in a String[], where most calls simply lists the arguments in the call:
          String[] opts = {Xmx, "-XX:NativeMemoryTracking=detail", "-XX:+UseParallelGC", "-version"};
          ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(opts);

        And some places put the args in a temporary Collection:
          LinkedList<String> vmOptions = new LinkedList<>();
          vmOptions.add(gc);
          vmOptions.add("-Xmx" + minMaxHeap);
          vmOptions.add("-XX:+PrintFlagsFinal");
          vmOptions.add(VerifyHeapSize.class.getName());

          ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[0]));

        I'd like to cleanup, simplify, and unify many of these usages.

        Attachments

          Issue Links

            Activity

              People

                stefank Stefan Karlsson
                stefank Stefan Karlsson
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: