X Tutup
Skip to content

Auto-port 5.0: Whitelist JMH annotation processing in microbench module#16429

Open
netty-project-bot wants to merge 1 commit into5.0from
auto-port-pr-16428-to-5.0
Open

Auto-port 5.0: Whitelist JMH annotation processing in microbench module#16429
netty-project-bot wants to merge 1 commit into5.0from
auto-port-pr-16428-to-5.0

Conversation

@netty-project-bot
Copy link
Contributor

Auto-port of #16428 to 5.0
Cherry-picked commit: 335d294


Motivation:

Starting from JDK 23, the annotation processing was disabled by default, see:
https://bugs.java.com/bugdatabase/JDK-8321314/description
https://mail.openjdk.org/pipermail/jdk-dev/2024-May/009028.html

This change breaks the microbench module because it relies on JMH annotation processors to generate benchmark code. For instance, when building with JDK 25, run the following command within the microbench module:

mvn clean install -Dcheckstyle.skip -Pbenchmark-jar

Then run the generated JAR(java -jar target/microbenchmarks.jar), and it results in the following error:

Error: Unable to access jarfile microbenchmarks.jar
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:253)
at org.openjdk.jmh.runner.Runner.run(Runner.java:209)
at org.openjdk.jmh.Main.main(Main.java:71)

Modification:

Whitelist the jmh-generator-annprocess in the microbench/pom.xml, with annotationProcessorPaths configuration, see:
https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#annotationProcessorPaths

Result:

Properly process the JMH annotation.

Motivation:

Starting from JDK 23, the annotation processing was disabled by default,
see:
https://bugs.java.com/bugdatabase/JDK-8321314/description
https://mail.openjdk.org/pipermail/jdk-dev/2024-May/009028.html

This change breaks the `microbench` module because it relies on JMH
annotation processors to generate benchmark code. For instance, when
building with JDK 25, run the following command within the `microbench`
module:

> mvn clean install -Dcheckstyle.skip -Pbenchmark-jar

Then run the generated JAR(`java -jar target/microbenchmarks.jar`), and
it results in the following error:

> Error: Unable to access jarfile microbenchmarks.jar
> 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:253)
>         at org.openjdk.jmh.runner.Runner.run(Runner.java:209)
>         at org.openjdk.jmh.Main.main(Main.java:71)

Modification:

Whitelist the `jmh-generator-annprocess` in the `microbench/pom.xml`,
with `annotationProcessorPaths` configuration, see:

https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#annotationProcessorPaths

Result:

Properly process the JMH annotation.

(cherry picked from commit 335d294)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup