Set a system property before forking

Weijun Wang weijun.wang at oracle.com
Tue Mar 28 06:29:10 UTC 2017


I have a system property that is used by Java in a very early stage, 
which means it has to be set on the command line with -Dx=y instead of 
inside a program with System.setProperty().

Now I'd like to write a benchmark to check how different values of this 
system property affect performance. I'm now able to provide the system 
property on the command line, run the benchmark multiple times, and 
compare the results. But is it possible to set it inside my benchmark 
with different values for different @Benchmark methods so I only need to 
run once? Since the @Benchmark methods run inside forked JVMs, I assume 
there is a way to set the system property before this forking.

Thanks
Max



More information about the jmh-dev mailing list