RFR: 8378110: Add -XX: prefix to settings-file flags in RuntimeMXBean.getInputArguments() [v2]
Kevin Walls
kevinw at openjdk.org
Fri Feb 27 10:05:25 UTC 2026
On Wed, 18 Feb 2026 16:50:27 GMT, Oli Gillespie <ogillespie at openjdk.org> wrote:
>> Flags passed via a settings file (`.hotspotrc`, or `-XX:Flags=my-file`) do not have the `-XX:` prefix like they would have if passed as command-line args. `JVM_GetVmArguments` then prints these flags also without the prefix, along with command-line flags that _are_ prefixed.
>>
>> However, users of `JVM_GetVmArguments` expect the arguments to be in a format that they can pass as command-line args, for example [in CDS static_dump](https://github.com/openjdk/jdk/blob/63f00fff921ed4ac0f595a0a013d399700433a2c/src/java.base/share/classes/jdk/internal/misc/CDS.java#L329-L338) - CDS static_dump currently *does not work* if the main VM uses flags from a settings file.
>>
>> So, always add the `-XX:` prefix to flags from settings files in `JVM_GetVmArguments`. Updated existing test to cover this behaviour.
>>
>> I looked for existing users of `JVM_GetVmArguments` and they either seem like they'll benefit from this change (CDS, JMH via `RuntimeMXBean.getInputArguments()`) or they won't care.
>>
>> **Testing**
>>
>> * Updated the existing InputArgument test with a case that verifies the new behaviour.
>> * Confirmed that CDS static_dump and JMH now work on a VM with flags from a file.
>
> Oli Gillespie has updated the pull request incrementally with one additional commit since the last revision:
>
> Remove @author tag and update copyright
Yes it would make more sense for the list seen by RuntimeMXBean to have the -XX prefix.
It is a change in some very long-standing behavior, so yes maybe release note.
test/jdk/java/lang/management/RuntimeMXBean/InputArgument.java line 97:
> 95:
> 96: List<String> options = rm.getInputArguments();
> 97: if (vmOptions == null) {
An existing problem in the test, but getInputArguments() says:
"returns an empty list if there is no input argument"
...so would be great if we can throw new RuntimeException("Null value from getInputArguments()") or simliar to cause a failure if it gets a null, while we are here.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29793#issuecomment-3971952560
PR Review Comment: https://git.openjdk.org/jdk/pull/29793#discussion_r2863528701
More information about the serviceability-dev
mailing list