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

Joe Darcy darcy at openjdk.org
Thu Oct 26 00:32:42 UTC 2023

On Wed, 25 Oct 2023 23:26:36 GMT, Josiah Noel <duke at openjdk.org> wrote:

> Just out of curiosity though, why didn't this (pretty sizable breaking change) get a JEP? The dynamic agents being disabled by default got one.

The short answer is despite the Sturm und Drang of any discussions on Reddit, I don't agree with the assessment that this PR constitutes a "pretty sizable breaking change."

To summarize: the capabilities of javac with respect to annotation processing are not changing in any way. The only aspect that is changing is what is the default policy if no explicit annotation processing configuration options are given.

If a build environment is already using any of the javac options `-processor`, `--processor-path`, `--processor-module-path`, or `-proc:only` nothing changes.

If a build environment does not have annotation processors on the class path, nothing changes.

In JDK 21, javac prints a note -- not a warning for a reason I'll explain below -- to identify the situations where implicit annotation processing is being relied on. Now it is true that users might not see this note, but communication about the JDK 21 change was publicized on the quality-discuss list to help make sure interested parties were informed of the change. The reason the javac message is a note and not a warning is so that build environments running under `-Werror` will not (spuriously) fail solely due to communicating the possibility of a future policy change.

Starting in JDK 21, a build environment or other javac invocation can be explicitly configured to request the old default policy by using `-proc:full`. All the other existing annotation processing configuration options (`-processor`, `-processor-path`, ...) are still supported and mean exactly the same thing as before.

Only in JDK 22 will the default policy actually be change to _not_ look on the class path for annotation processors (unless `-proc:full` is also given). However, there need not be any flag day for changing to JDK 22 specifically since the option to request the old policy is accepted in JDK 21.


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

More information about the compiler-dev mailing list