JMH and JDK9
Alan Bateman
Alan.Bateman at oracle.com
Wed Mar 30 16:12:53 UTC 2016
On 30/03/2016 17:09, Andrew Haley wrote:
> 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?
>
There is discussion on this in this bug:
https://bugs.openjdk.java.net/browse/JDK-8152842
but in the mean-time it looks like JMH no longer uses @Generated.
-Alan
More information about the hotspot-dev
mailing list