Bug in -jvmArgs parsing?
Dries Samyn
mail at dries.net
Fri Aug 15 06:31:24 UTC 2025
Hi Kirk,
I don't think it is the shell that is splitting the value as the jvmArgs is
quoted, I think it is when the argument is parsed.
I tried \ escaping the spaces as well.
java -jar build/libs/jmh-spaces-bug-reproduction-jmh.jar \
-jvmArgs "-javaagent:/tmp/agent with spaces/dummy.jar"
java -jar build/libs/jmh-spaces-bug-reproduction-jmh.jar \
-jvmArgs "-javaagent:/tmp/agent\ with\ spaces/dummy.jar"
I can see the the description of the flag suggest it is a space
space-separated line, which makes me think this is intended behaviour,
however, I cannot understand how a value containing spaces can then be used:
-jvmArgs <string> Use given JVM arguments. Most options are
inherited
from the host VM options, but in some cases
you want
to pass the options only to a forked VM.
Either single
space-separated option line, or multiple
options
are accepted. This option only affects forked
runs.
Dires.
On Thu, 14 Aug 2025, 8:08 am Kirk Pepperdine, <kirk.pepperdine at gmail.com>
wrote:
> Hi Dries,
>
> Have you tried escaping the spaces to that the shell doesn’t split the
> value?
>
> Kind regards,
> Kirk
>
>
> On Aug 13, 2025, at 7:59 PM, Dries Samyn <mail at dries.net> wrote:
>
> I'm not sure this is considered a bug as it matches the documented
> behaviour, but I can't think of a clean workaround if it is.
>
> I believe arguments passed into the -jvmArgs option are space delimited.
> However, this is problematic when those arguments include spaces as part of
> the value.
> For example, I am trying to create a custom profiler for YourKit
> integration, but the YourKit agent, by default, has spaces in its path on
> MacOs, which means trying to pass it in the jvmArgs option is problematic.
>
> I have created a reproduction of the issue and explanation here:
> https://github.com/driessamyn/jmh-spaces-bug-reproduction
>
> Looking forward to hearing thoughts on this.
>
> Dries.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jmh-dev/attachments/20250815/04199c6f/attachment.htm>
More information about the jmh-dev
mailing list