RFR: 7903908: JMH: Helpful message when benchmark builds are misconfigured
Aleksey Shipilev
shade at openjdk.org
Thu Dec 12 12:25:24 UTC 2024
On Thu, 12 Dec 2024 12:20:39 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> When JMH benchmark project is misconfigured, the runner would print an unhelpful error like:
>
>
> Exception in thread "main" java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList
> at org.openjdk.jmh.runner.AbstractResourceReader.getReaders(AbstractResourceReader.java:98)
> at org.openjdk.jmh.runner.BenchmarkList.find(BenchmarkList.java:124)
> at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:252)
> at org.openjdk.jmh.runner.Runner.run(Runner.java:208)
> at org.openjdk.jmh.Main.main(Main.java:71)
>
>
> This is especially often when JDK 23 disabled annotation processors by default. We need to print more helpful message to guide users to resolution.
Now prints:
Exception in thread "main" java.lang.RuntimeException:
Internal error reading resource file: Unable to find /META-INF/BenchmarkList
This often indicates a build configuration problem. Common causes are:
1. Annotation processing is not enabled or configured incorrectly.
Note that JDK 23+ disables running annotation processors by default,
which affects projects that used to build fine with older JDKs.
Check if you need to add a relevant option to your compiler plugin.
For example, maven-compiler-plugin can be configured like this:
<configuration>
<annotationProcessors>
<annotationProcessor>org.openjdk.jmh.generators.BenchmarkProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
2. Multi-module benchmark builds have not merged the resource files.
Check if you need to add a relevant config to your build.
For example, maven-shade-plugin needs to explicitly enable resource transformers:
https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
at org.openjdk.jmh.runner.AbstractResourceReader.internalError(AbstractResourceReader.java:114)
at org.openjdk.jmh.runner.AbstractResourceReader.getReaders(AbstractResourceReader.java:88)
at org.openjdk.jmh.runner.BenchmarkList.find(BenchmarkList.java:124)
at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:252)
at org.openjdk.jmh.runner.Runner.run(Runner.java:208)
at org.openjdk.jmh.Main.main(Main.java:71)
-------------
PR Comment: https://git.openjdk.org/jmh/pull/143#issuecomment-2538755812
More information about the jmh-dev
mailing list