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

Support optional arguments in ProcessTools.createJavaProcessBuilder

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • None
    • other-libs

      The jdk.test.lib.process.ProcessTools.createJavaProcessBuilder API is inconvenient when you want to pass some arguments only under certain conditions. You either have to build an ArrayList of arguments, or do hacks like this

      ProcessTools.createJavaProcessBuilder("-cp", "foobar",
          Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "-Dx",
          "TestApp");

      This RFE proposes an enhancement to the API, so you can do things like:

      ProcessTools.createJavaProcessBuilder("-cp", "foobar",
          ifDebug.use("-XX:-VerifyDependencies"),
          "TestApp");

      ProcessTools.createJavaProcessBuilder("-cp", "foobar",
          "TestApp",
           ifCond(x == 0).use("x", "is", "zero").orElse().use("not", "zero"));

      Note that the second example cannot be done with the current API. I.e., something like the following is not valid Java syntax.

      ProcessTools.createJavaProcessBuilder("-cp", "foobar",
          "TestApp",
           (x == 0) ? {"x", "is", "zero"} : {"not", "zero"});

      See attachment for a rough draft of the proposal

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: