AW: Can't fork VM if option value contains space
Dmitry Vyazelenko
vyazelenko at yahoo.com
Tue Aug 12 12:09:18 UTC 2014
Update (see below).
On Tuesday, August 12, 2014 1:34 PM, Dmitry Vyazelenko <vyazelenko at yahoo.com> wrote:
Well it is even more strange on Windows:
- On command line:
FAILS: java -jar target\benchmarks.jar -jvmArgs -Dmy.prop="A B C"
Does not start benchmark execution.
WORKS: java -jar target\benchmarks.jar -jvmArgs -Dmy.prop="\"A B C\""
Runs and produces this result:
Iteration 1: my.prop ==> A B C
- Using Java API:
FAILS: new OptionsBuilder()
.jvmArgs("-Dmy.prop=\"A B C\"").build();
Does not fork VM.
WORKS: new OptionsBuilder()
.jvmArgs("-Dmy.prop=\"\"A B C\"\"").build();
Runs but produces wrong result:
Iteration 1: my.prop ==> "A B C"
FAILS: new OptionsBuilder()
.jvmArgs("-Dmy.prop=\"\\\"A B C\\\"\"").build();
Does not fork VM.
RUNS: new OptionsBuilder()
.jvmArgs("-Dmy.prop=\\\"A B C\\\"").build();
Runs but produces wrong result:
Iteration 1: my.prop ==> "A B C"
WORKS (no quoting): new OptionsBuilder()
.jvmArgs("-Dmy.prop=A B C").build();
Runs and produces correct result:
Iteration 1: my.prop ==> A B C"
Best regards,
Dmitry
On Tuesday, August 12, 2014 12:52 PM, Bernd Eckenfels <ecki at zusammenkunft.net> wrote:
It us not meant as a solution for Windows. There is no useful semantics in the command parser of Windows, just dont use it for stuff like that. It should work on most shells (mac,linux)
having said that i somewhat wonder why the original syntax did not work on OSX, it should preserv blanks when passed on with the right process API and no "/bin/sh -c".
gruss
Bernd
--
http://bernd.eckenfels.net
----- Ursprüngliche Nachricht -----
Von: "vyazelenko at yahoo.com" <vyazelenko at yahoo.com>
Gesendet: 12.08.2014 12:24
An: "Bernd Eckenfels" <ecki at zusammenkunft.net>
Cc: "Aleksey Shipilev" <aleksey.shipilev at oracle.com>; "jmh-dev at openjdk.java.net" <jmh-dev at openjdk.java.net>
Betreff: Re: Can't fork VM if option value contains space
The solution from Bernd with single quotes around entire property does not work (at least on Windows), because entire thing is passed as String:
VM options: '-Dmy.prop=A B C'
Note also that double quotes are gone.
@Aleksey:
- Original issue described is reproducible on Windows and Mac OS X. Try to pass property via -jvmArgs instead of passing it directly to java launcher.
- Quoting the quotes, i.e.:
-jvmArgs -Dmy.prop="\"A B C\""
Works on Windows but fails on Mac OS X.
- Using runner API just works. :)
Best regards,
Dmitry
Sent from my iPhone
> On Aug 12, 2014, at 1:45, Bernd Eckenfels <ecki at zusammenkunft.net> wrote:
>
> Am Tue, 12 Aug 2014 03:22:16 +0400
> schrieb Aleksey Shipilev <aleksey.shipilev at oracle.com>:
>> ...this points to the shell escaping troubles in your shell, when you
>> pass the command line. Try to meddle with escaping both quotes and the
>> backslashes? E.g.:
>>
>> java -jar target/benchmarks.jar -jvmArgs -Dmy.property=\\\"A B C\\\"
>
> Or try this: java -jar target/benchmarks.jar -jvmArgs '-Dmy.property="A
> B C"'
>
> Gruss
> Bernd
More information about the jmh-dev
mailing list