JMH and JDK9

Andrew Haley aph at redhat.com
Wed Mar 30 16:09:06 UTC 2016


I'm totally stuck trying to use jmh to test my JDK9 code.  I can't
build JMH itself with JDK9 because I get a weird error in some Eclipse
classes in Maven.  So, I've tried to run Maven with JDK8 but use a
seprarate javac which point to JDK9/bin/javac.

When I try to compile my code against JDK9 I always get:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:testCompile (default-testCompile) on project jmh-core-it: Compilation failure
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
...
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:749)
        at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:152)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 20 more

and, after much digging, the root of this seems to be

error: Annotation generator had thrown the exception. java.lang.NoClassDefFoundError: javax/annotation/Generated

My guess is that this has something to do with modules, but I don't
know that for sure.  I need to compile my test code against JDK9
because the methods I'm testing do not exist in JDK8.

Is there a recipe for using JMH with JDK9 classes?  What do people do?

Andrew.


More information about the hotspot-dev mailing list