JMH does not recognise @State annotation on Groovy classes

Gabor Nagy nagyga1 at gmail.com
Mon Oct 19 06:31:26 UTC 2015


E.g:

JmhModelsX.groovy:

@State(Scope.Thread)
class JmhModelsX {

    private double total

    @Benchmark
    public void test() {
        total = total + 23.0;
    }

    public static void main(String[] args) throws IOException, RunnerException {
        Options opt = new OptionsBuilder()
                .include(".*" + JmhModelsX.class.getSimpleName() + ".*")
                .forks(1)
        // for fast debug
                .warmupIterations(3).measurementIterations(3)
                .build();
        new Runner(opt).run();
    }
}


[ERROR]
/home/xxx/git/cpox-opt/cpox-opt-pom/rater/src/test/java/benchmarks/JmhModelsX.groovy:[14,-1]
[ERROR] 3. ERROR in
/home/xxx/git/cpox-opt/cpox-opt-pom/rater/src/test/java/benchmarks/JmhModelsX.groovy
(at line 14)
[ERROR] private double total
[ERROR] ^^^^^
[ERROR] Field "total" is declared within the class not having @State
annotation. This can result in unspecified behavior, and prohibited.


More information about the jmh-dev mailing list