Setting classpath with benchmark.java
Dmitry Timofeiev
dmitry.timofeiev at gmail.com
Fri Sep 14 05:44:39 UTC 2018
Hi Alan,
I don't have a solution to setting a classpath at runtime — and it also
seems the shade plugin does not support including non-maven artifacts
[1]. Would it be possible in your case to install the library in your
local (or company) artefact repository to have the shade plugin include
it into benchmark.jar as a dependency of your SuT/benchmark project?
[1]
https://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html
[2] https://stackoverflow.com/a/27646585/1792188
Cheers,
Dmitry
On 12.09.18 19:48, Alan Burlison wrote:
> I'm trying to run a benchmark which needs a specific classpath
> setting, to include a library that isn't available via Maven.
>
> Unfortunately it seems to be impossible to set the classpath with jmh.
> I'm using "-jvmArgs '-Djava.class.path=/opt/instantclient/ojdbc8.jar"
> to try to do so but here's the resulting command-line that's used to
> run the target VM by benchmark.java:
>
> Forking 10 times using command:
> [/usr/lib/jvm/oracle-java8-jdk-amd64/jre/bin/java, -cp,
> /opt/instantclient/ojdbc8.jar, -Djava.library.path=/opt/instantclient,
> -Dargs.mode=thin,
> -XX:CompileCommandFile=/tmp/jmh8572122209057614698compilecommand, -cp,
> target/benchmarks.jar, org.openjdk.jmh.runner.ForkedMain, 127.0.0.1,
> 43795]
>
> Because benchmark.java is appending "-cp target/benchmarks.jar" the
> second "-cp" wins and overrides the one specified with "-jvmArgs". I
> can't imagine I'm the first person to have needed to set the classpath
> for a jmh benchmark but I haven't been able to find any way around the
> problem, and it is a showstopper for me.
>
> Thanks,
>
More information about the jmh-dev
mailing list