RFR: CODETOOLS-7903008: JMH: Support incremental annotation processing for Gradle Java plugin

Taylor Wicksell github.com+301239+twicksell at openjdk.java.net
Wed Aug 25 22:13:42 UTC 2021


On Fri, 6 Aug 2021 07:23:22 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Please hold off on merging. After running through some more complex benchmark examples, I've found a place where we are not using Filer to write classes. `StateObjectHandler.writeStateOverrides` seems problematic. Looking to see if I can fix that.
>
>> Please hold off on merging. After running through some more complex benchmark examples, I've found a place where we are not using Filer to write classes. `StateObjectHandler.writeStateOverrides` seems problematic. Looking to see if I can fix that.
> 
> I don't see a problem there? `StateObjectHandler.writeStateOverrides` delegates to `GeneratorDestination.newClass`, which in calls `APGeneratorDestination.newClass` in annotation processing mode, which uses `Filer`.

Sorry for the delay @shipilev this took a fair bit of time to dig through. The error I encountered here I believe is a gradle bug with the Aggregating strategy, as it only occurs on some of the later versions of Gradle. I can share a test harness if you're interested, but essentially you need to trigger incremental compilation for a class *other* than a JMH benchmark to observe the failure.  

I was unable to find a helpful solution on the Gradle side and the code does not have very much (any) documentation to assist with understanding what assumptions Gradle's incremental compiler has made. Instead, I was able to resolve this by using the Isolating strategy, which unfortunately required a change to JMH to pass the originating elements to the `Filer` when creating new classes. The end result is better overall from the perspective of providing useful information to the compiler, and according to Gradle should be more performant. However, I did have to make some changes to allow for passing this information. 

I tried to do this with as little refactoring as possible, but please let me know what you think.

-------------

PR: https://git.openjdk.java.net/jmh/pull/43


More information about the jmh-dev mailing list