Can't fork VM if option value contains space
Aleksey Shipilev
aleksey.shipilev at oracle.com
Mon Aug 11 23:22:16 UTC 2014
Hi again Dmitry,
On 08/12/2014 01:48 AM, Dmitry Vyazelenko wrote:
> Just got into some trouble passing JVM options to forked VMs when values have a space, i.e.
> I want to pass the following option (via -jmvArgs) when executing benchmarks:
> -Dmy.option=“A B C”
>
> What I get is the following error:
> java -jar target/benchmarks.jar -jvmArgs -Dmy.property="A B C"
> # VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/bin/java
> # VM options: -Dmy.property=A B C
> # Warmup: 20 iterations, 1 s each
> # Measurement: 20 iterations, 1 s each
> # Threads: 1 thread, will synchronize iterations
> # Benchmark mode: Throughput, ops/time
> # Benchmark: test.jmh.DummyBench.baseline
>
> # Run progress: 0.00% complete, ETA 00:06:40
> # Fork: 1 of 10
> Error: Could not find or load main class B
> <forked VM failed with exit code 1>
> <stdout last='10 lines'>
> </stdout>
> <stderr last='10 lines'>
> Error: Could not find or load main class B
> </stderr>
This seems to be Mac OS specific, since on my Linux it works perfectly well:
$ java -DmyOption="A B C" -jar jmh-samples/target/benchmarks.jar
".*01_HelloWorld.*"
> The only workaround I’ve found is to use Java API:
> Options options = new OptionsBuilder().jvmArgs("-Dmy.property=\"A B C\"").build();
...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\\\"
Thanks,
-Aleksey.
More information about the jmh-dev
mailing list