Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMH doesn't run inside a Java Module (Unable to find the resource: /META-INF/BenchmarkList)

I took a project that uses maven-surefire-plugin (automated tests) to trigger JMH benchmarks and added module-info.java to it. Now, META-INF/BenchmarkList is no longer getting generated (in fact, the entire directory is missing) so I end up with the following error when launching the benchmarks:

ERROR: Unable to find the resource: /META-INF/BenchmarkList

I suspect that Java Modules is preventing the annotation processor from running properly, but I can't figure out how to fix it. Any ideas?

like image 513
Gili Avatar asked Oct 28 '25 13:10

Gili


1 Answers

I figured it out through trial and error. It looks like a bug (or "feature") in maven-compiler-plugin 3.8.0. When module-info.java is present, the JMH annotation processor is no longer picked up automatically. Adding this configuration fixed the problem for me:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    [...]
        <annotationProcessorPaths>
            <path>
                <groupId>org.openjdk.jmh</groupId>
                <artifactId>jmh-generator-annprocess</artifactId>
                <version>${jmh.version}</version>
            </path>
        </annotationProcessorPaths>
    [...]
    </configuration>
</plugin>

UPDATE: I filed a bug report against maven-compiler-plugin.

like image 106
Gili Avatar answered Oct 30 '25 04:10

Gili



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!