Add -XX: prefix to settings-file flags in RuntimeMXBean.getInputArguments()

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: hotspot
    • None

      Flags passed via a settings file, either the default .hotspotrc or an explicit -XX:Flags argument, do not have the -XX: prefix when returned by JVM_GetVmArguments. This is problematic for anyone wanting to understand or use those flags, how does a user know which are -XX: flags and which aren't? One use-case would be to pass the JVM flags of the current JVM to a child process, but JVM_GetVmArguments cannot be passed as-is because of the missing prefix.

      ```flags.txt
       -UseParallelGC
       MaxHeapSize=1000000000
      ```

      ```Test.java
      void main() {
          IO.println(java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments());
      }
      ```


      ```
      java -XX:Flags=flags.txt -XX:+UseG1GC Test.java
      [-UseParallelGC, MaxHeapSize=1000000000, -XX:Flags=flags.txt, -XX:+UseG1GC, --add-modules=ALL-DEFAULT]
      ```

      The flags from flags.txt do not have -XX: prefix, but are mixed in with the command-line args which are prefixed. We should add the prefix in JVM_GetVmArguments, for user convenience.

            Assignee:
            Oli Gillespie
            Reporter:
            Oli Gillespie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: