RFR: JDK-8306819: Consider disabling the compiler's default active annotation processing

Joe Darcy darcy at openjdk.org
Mon Sep 11 21:25:39 UTC 2023


On Mon, 11 Sep 2023 17:10:01 GMT, David M. Lloyd <duke at openjdk.org> wrote:

> > > This aims to avoid unintentional AP pollutions in classpath, like if one AP is present in a dependency and thus your classpath but you don't want it to run.
> > 
> > 
> > In practice is this a thing that happens? Most processors I've seen (like Lombok or record builder for example) are typically added as provided or optional scope dependencies. (and so cannot be transitively pulled)
> 
> In fact this is a thing that can cause problems. At present, annotation processor authors have to be cautious about including dependencies because commonly used libraries (such as Guava or Eclipse Collections) can conflict with other processors and/or the user's project with surprising (and sometimes subtle) results.
> 
> I'm not sure about other build tools, but Maven does supply a means to include an annotation processor on a (relatively) isolated class path, i.e. separately from the application's class path. Though this is somewhat more cumbersome, it is certainly safer.

Yes, in terms of good build hygiene, I recommend separately specifying the path for annotation processors and the path for general compiler dependencies, even if they happen to be the same path.

Likewise,, specifying --release $N is a good practice too.

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

PR Comment: https://git.openjdk.org/jdk/pull/14432#issuecomment-1714598354


More information about the compiler-dev mailing list