JMH does not recognise @State annotation on Groovy classes

Aleksey Shipilev aleksey.shipilev at oracle.com
Tue Oct 20 08:40:16 UTC 2015


Ah, so you are using Groovy Eclipse compiler. This configuration was
never tested, and it is not "officially" supported. Please see how the
Groovy benchmarks bootstrapped from archetypes are working. I see your
original POM was from the archetype, so you must be trying to do
something out of the recommended way, capturing the errors along the way ;)

I traced the error a bit, and can conclude that Element.getAnnotation()
returns null when trying to look up @State on com.test.app.MyBenchmark.
In fact, even getAnnotationMirrors() returns the empty array. Element
implementation is provided by the compiler, and therefore I believe the
problem you are facing is the compiler issue, not the JMH one.

Thanks,
-Aleksey

On 10/19/2015 05:24 PM, Gabor Nagy wrote:
> Hope the attachment goes through.
> 
> Don't scold me if it is something moronic...
> 
> groovy-all 2.4.3
> maven-compiler-plugin 3.1
> groovy-eclipse-compiler 2.9.2-01
> groovy-eclipse-batch
> 
> mvn clean compile
> [INFO] Scanning for projects...
> [INFO]                                                                        
> 
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building JMH benchmark sample: Groovy 1.0-SNAPSHOT
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-app ---
> [INFO] Deleting /tmp/my-app/my-app/target
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> my-app ---
> [INFO] Using 'UTF-8' encoding to copy filtered resources.
> [INFO] skip non existing resourceDirectory
> /tmp/my-app/my-app/src/main/resources
> [INFO] skip non existing resourceDirectory
> /tmp/my-app/my-app/src/main/resources.filtered
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my-app ---
> [INFO] Changes detected - recompiling the module!
> [INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
> [INFO] -------------------------------------------------------------
> [ERROR] COMPILATION ERROR :
> [INFO] -------------------------------------------------------------
> [ERROR]
> /tmp/my-app/my-app/src/main/java/com/test/app/MyBenchmark.groovy:[41,8]
> 1. ERROR in
> /tmp/my-app/my-app/src/main/java/com/test/app/MyBenchmark.groovy (at
> line 41)
>     double something;
>            ^^^^^^^^^
> Field "something" is declared within the class not having @State
> annotation. This can result in unspecified behavior, and prohibited.
> 
> [ERROR] Found 1 error and 0 warnings.
> [INFO] 2 errors
> [INFO] -------------------------------------------------------------
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 2.071 s
> [INFO] Finished at: 2015-10-19T22:19:59+08:00
> [INFO] Final Memory: 13M/163M
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
> (default-compile) on project my-app: Compilation failure: Compilation
> failure:
> [ERROR]
> /tmp/my-app/my-app/src/main/java/com/test/app/MyBenchmark.groovy:[41,8]
> 1. ERROR in
> /tmp/my-app/my-app/src/main/java/com/test/app/MyBenchmark.groovy (at
> line 41)
> [ERROR] double something;
> [ERROR] ^^^^^^^^^
> [ERROR] Field "something" is declared within the class not having @State
> annotation. This can result in unspecified behavior, and prohibited.
> [ERROR]
> [ERROR] Found 1 error and 0 warnings.




More information about the jmh-dev mailing list