Bug: JMH APT processor claims all annotations
aleksey.shipilev at gmail.com
Mon Sep 5 07:37:49 UTC 2016
Yes, sorry about that, should be fixed with:
On 08/11/2016 07:10 AM, Dimitar Dimitrov wrote:
> When a codebase using JMH also uses other annotation processors (i.e.
> Lombok, Dagger 2, etc) The other processors will not get a chance to run if
> they are ordered after JMH.
> Root cause:
> The JMH BenchmarkProcessor#process() method returns unconditionally true
> regardless of whether it processed an annotation or not.
> According to the Javadoc, if a processor returns true, it will "claim" the
> annotation for itself and no other processors will be given a chance to
> process it.
> Proposed fix:
> I am not deeply familiar with JMH, but for what I know, it has a closed set
> of annotations, so line 41 in on BenchmarkProcessor.java to:
> If JMH allows user-defined annotations things get a bit more complicated.
> If the user-defined annotations are known in advance, one can override
> if there is a need to dynamically support user defined annotations, one
> needs to inspect the first arg of the process() method and sure that it
> returns true only in cases where all annotations are for JMH.
> AFinally, a simpler option is for the main processor to always return false
> and add a separate processor that doesn't do anything else but claim the
> known JMH annotations. That covers most cases, though that may result in
> javac warning (-Xlint:processing) with user-defined annotations.
> Best regards,
More information about the jmh-dev