<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello Maurizio,</p>
<p>We had this issue in our JDK repo which has micro benchmarks.
Running those micro benchmarks had run into this issue. We decided
to use the "-processor
org.openjdk.jmh.generators.BenchmarkProcessor" instead of
-proc:full to get this to work. More details are available here
<a class="moz-txt-link-freetext" href="https://github.com/openjdk/jdk/pull/16122">https://github.com/openjdk/jdk/pull/16122</a></p>
<p>-Jaikiran<br>
</p>
<div class="moz-cite-prefix">On 31/10/23 7:44 pm, Maurizio
Cimadamore wrote:<br>
</div>
<blockquote type="cite"
cite="mid:986933cd-c9a0-4003-857f-bb2aadbacd84@oracle.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div class="markdown-here-wrapper" data-md-url="" style="">
<p style="margin: 0px 0px 1.2em !important;">Hi,<br>
earlier today I ran into an issue when trying to run a JMH
benchmark on a 3rd party maven project.</p>
<p style="margin: 0px 0px 1.2em !important;">It seems like the
issue is caused by the change in javac’s default annotation
processing policy [1].</p>
<p style="margin: 0px 0px 1.2em !important;">Here are the steps
to reproduce the issue:</p>
<ul style="margin: 1.2em 0px;padding-left: 2em;">
<li style="margin: 0.5em 0px;">set JAVA_HOME to point to a
recent JDK 22 build</li>
<li style="margin: 0.5em 0px;">generate a JMH sample pom file
using the following command (this is what is advertised in
the JMH github page [2]):</li>
</ul>
<pre
style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em; line-height: 1.2em;margin: 1.2em 0px;"><code
style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-radius: 3px; display: inline;white-space: pre; overflow: auto; border-radius: 3px; border: 1px solid rgb(204, 204, 204); padding: 0.5em 0.7em; display: block !important;">$ mvn archetype:generate \
-DinteractiveMode=false \
-DarchetypeGroupId=org.openjdk.jmh \
-DarchetypeArtifactId=jmh-java-benchmark-archetype \
-DgroupId=org.sample \
-DartifactId=test \
-Dversion=1.0
</code></pre>
<ul style="margin: 1.2em 0px;padding-left: 2em;">
<li style="margin: 0.5em 0px;">build the project using <code
style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-radius: 3px; display: inline;">mvn clean package</code></li>
<li style="margin: 0.5em 0px;">run the benchmark as follows:</li>
</ul>
<pre
style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em; line-height: 1.2em;margin: 1.2em 0px;"><code
style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-radius: 3px; display: inline;white-space: pre; overflow: auto; border-radius: 3px; border: 1px solid rgb(204, 204, 204); padding: 0.5em 0.7em; display: block !important;">$ $JAVA_HOME/bin/java -jar target/benchmarks.jar MyBenchmark
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)
</code></pre>
<p style="margin: 0px 0px 1.2em !important;">As you can see,
there is a problem here, as the META-INF folder does not
contain the list of benchmarks. This is due to the fact that
annotations are no longer processed using processors available
in the classpath. Using JDK 21 to build and run the same pom
file works fine.</p>
<p style="margin: 0px 0px 1.2em !important;">Adding the
following lines to the compiler plugin configuration addresses
the issue in JDK 22:</p>
<pre
style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em; line-height: 1.2em;margin: 1.2em 0px;"><code
style="font-size: 0.85em; font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em; padding: 0px 0.3em; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-radius: 3px; display: inline;white-space: pre; overflow: auto; border-radius: 3px; border: 1px solid rgb(204, 204, 204); padding: 0.5em 0.7em; display: block !important;"> <compilerArgs>
<arg>-proc:full</arg>
</compilerArgs>
</code></pre>
<p style="margin: 0px 0px 1.2em !important;">While this is
understandable, I’m afraid that not many users will have
gotten the memo - I don’t seem to get any notes when building
this project using JDK 21 (probably the notes are swallowed by
maven?). And, sadly, the lack of a proper JMH plugin means
that all the JMH poms out there will need some manual tweaking
to keep working in 22.</p>
<p style="margin: 0px 0px 1.2em !important;">At the very least,
I think that JMH’s maven archetype should be updated to
include the lines above?</p>
<p style="margin: 0px 0px 1.2em !important;">Cheers<br>
Maurizio</p>
<p style="margin: 0px 0px 1.2em !important;">[1] - <a
href="https://github.com/openjdk/jdk/pull/14432"
class="moz-txt-link-freetext" moz-do-not-send="true">https://github.com/openjdk/jdk/pull/14432</a><br>
[2] - <a href="https://github.com/openjdk/jmh"
class="moz-txt-link-freetext" moz-do-not-send="true">https://github.com/openjdk/jmh</a></p>
<div
title="MDH:PHA+SGksPGJyPmVhcmxpZXIgdG9kYXkgSSByYW4gaW50byBhbiBpc3N1ZSB3aGVuIHRyeWluZyB0
byBydW4gYSBKTUggYmVuY2htYXJrIG9uIGEgM3JkIHBhcnR5IG1hdmVuIHByb2plY3QuPC9wPjxw
Pkl0IHNlZW1zIGxpa2UgdGhlIGlzc3VlIGlzIGNhdXNlZCBieSB0aGUgY2hhbmdlIGluIGphdmFj
J3MgZGVmYXVsdCBhbm5vdGF0aW9uIHByb2Nlc3NpbmcgcG9saWN5IFsxXS48L3A+SGVyZSBhcmUg
dGhlIHN0ZXBzIHRvIHJlcHJvZHVjZSB0aGUgaXNzdWU6PHA+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