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

Joe Darcy darcy at openjdk.org
Mon Sep 11 16:39:43 UTC 2023


On Mon, 12 Jun 2023 23:49:51 GMT, Joe Darcy <darcy at openjdk.org> wrote:

> Change annotation processing to be opt-in rather than opt-out.

> For whoever wondering about the impact of this breaking change, in JDK 21, the previous release and the previous LTS release, there's a new warning when the default active AP is used: #14499 https://bugs.openjdk.org/browse/JDK-8310061

To expand on and reiterate points already made by @liach , the goal here is only to change whether or not annotation processing is run implicitly in a case like

`javac -cp $CLASSPATH file`

 Accomplishing this is being broken up over (at least) two releases. In JDK 21, there were two related changes:
 
 [JDK-8308245](https://bugs.openjdk.org/browse/JDK-8308245): Add -proc:full to describe current default annotation processing policy
  [JDK-8310061] (https://bugs.openjdk.org/browse/JDK-8310061): Note if implicit annotation processing is being used

The `-proc:full` option corresponds to the long-standing old default policy on annotation processing. Quoting the note added in the second bug,

    Annotation processing is enabled because one or more processors were found
    on the class path. A future release of javac may disable annotation processing
    unless at least one processor is specified by name (-processor), or a search
    path is specified (--processor-path, --processor-module-path), or annotation
    processing is enabled explicitly (-proc:only, -proc:full).
    Use -Xlint:-options to suppress this message.
    Use -proc:none to disable annotation processing.

The message is a note rather than a waning to avoid tripping up people who run their builds with `-Werror`. Besides a release note in JDK 21, we did extra outreach on the quality discuss alias to publicize this change (https://mail.openjdk.org/pipermail/quality-discuss/2023-July/001122.html).

So, starting in JDK 21, if you want to get the old look-on-the-classpath behavior, it is sufficient to use `-proc:full`. This also will work in JDK 22 after the changes in this PR go back. Breaking the change up over multiple release helps avoid a more disruptive flag day since `-proc:full` can be used before and after to request the desired behavior. HTH

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

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


More information about the compiler-dev mailing list