Could not run jmh test in java9

So basically I am trying to run a test in the form:

@Benchmark
@Fork(jvmArgsAppend = "-Djava.lang.invoke.stringConcat=java.lang.invoke.StringConcatFactory.Strategy.BC_SB", value = 1)
public String java9StringBuilder(ThreadState state) {
    // some implementation here
}

Launch with:

java -jar benchmarks.jar MyFullClassNameHere -v extra

Unfortunately, it fails with forked VM failed with exit code 1no more "detailed" output.

What am I doing wrong?

I get the following warnings:

WARNING: Unknown module: org.openjdk specified for -add-exports

WARNING: Illegal reflection access operation has occurred

WARNING: Illegal Reflective Access by org.openjdk.jmh.util.Utils (file: /Path/Here/benchmarks.jar) in the java.io.Console.cs field

WARNING. Please think about this org.openjdk.jmh.util.Utils developer community.

WARNING. Use -illegal-access = warn to enable warnings of further illegal activities with reflective access.

.

+4
1

Java 9. JVM , JMH? , , :

- @Fork(jvmArgs = "-Djava.lang.invoke.stringConcat=java.lang.invoke.StringConcatFactory.Strategy.BC_SB")
+ @Fork(jvmArgs = "-Djava.lang.invoke.stringConcat=BC_SB")

... BC_SB - java.lang.invoke.StringConcatFactory.Strategy enum.

+6

Source: https://habr.com/ru/post/1689900/


All Articles