Java Cup
Inside Java

News and views from members of the Java team at Oracle

Quality Outreach Heads-up - JDK 23: Changes Default Annotation Processing Policy

The OpenJDK Quality Group is promoting the testing of FOSS projects with OpenJDK builds as a way to improve the overall quality of the release. This heads-up is part of a regular communication sent to the projects involved. To learn more about the program, and how-to join, please check here.

JDK 23: Changes Default Annotation Processing Policy

Annotation processing is a compile-time feature, where javac scans the to-be-compiled source files for annotations and then the class path for matching annotation processors, so they can generate source code. Up to JDK 22, this feature is enabled by default, which may have been reasonable when it was introduced in JDK 6 circa 2006, but from a current perspective, in the interest of making build output more robust against annotation processors being placed on the class path unintentionally, this is much less reasonable. Hence, starting with JDK 23, javac requires an additional command-line option to enable annotation processing.

New -proc Value

To that end, the pre-existing option -proc:$policy was extended, where $policy can now have the following values:

Up to and including JDK 22, code bases that require annotation processing before compilation could rely on javac's default behavior to process annotations but that is no longer the case. Starting with JDK 23, at least one annotation-processing command line option needs to be present. If neither -processor, --processor-path, nor --processor-module-path is used, -proc:only or -proc:full has to be provided. In other words, absent other command line options, -proc:none is the default on JDK 23.

Migration to -proc:full

Several measures were undertaken to help projects prepare for the switch to -proc:full:

With -proc:full backported, it is possible to configure a build that will work the same before and after the change in javac's default policy.

More Details

This is a summary, for more details make sure to read the original proposal.

~