JDK-8321319 : Reinstate disabling the compiler's default active annotation processing
  • Type: CSR
  • Component: tools
  • Sub-Component: javac
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 23
  • Submitted: 2023-12-05
  • Updated: 2024-11-19
  • Resolved: 2024-05-25
Related Reports
CSR :  
Relates :  
Relates :  
Relates :  
Description
Summary
-------

Reinstate the policy changes originally made under  JDK-8317544: stop running annotation processors found on the class path by default. That behavior can still be enabled by using one or more separate options.

Problem
-------

Starting in JDK 21, the message printed by JDK-8310061 is:

    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.

This CSR is to implement the future disabling described in the message above.

Solution
--------
Without other configuration options, do not search the class path for annotation processors.

In more detail, the only change in behavior occurs when the class path is set and no explicit annotation processing configuration is set.

Specification
-------------
Update to `javac` man page:

    diff --git a/src/jdk.compiler/share/man/javac.1 b/src/jdk.compiler/share/man/javac.1
    index de374e7d0c7..fe03bab8b45 100644
    --- a/src/jdk.compiler/share/man/javac.1
    +++ b/src/jdk.compiler/share/man/javac.1
    @@ -1712,8 +1712,15 @@ The API for annotation processors is defined in the
     packages and subpackages.
     .SS How Annotation Processing Works
     .PP
    -Unless annotation processing is disabled with the
    -\f[B]\f[VB]-proc:none\f[B]\f[R] option, the compiler searches for any
    +Annotation processing is requested by using an option to configure
    +annotation processing, such as \f[B]\f[VB]-processor\f[B]\f[R],
    +\f[B]\f[VB]--processor-path\f[B]\f[R],
    +\f[B]\f[VB]--processor-module-path\f[B]\f[R] or by explicitly enabling
    +processing with the \f[B]\f[VB]-proc:full\f[B]\f[R] or
    +\f[B]\f[VB]-proc:only\f[B]\f[R] options.  Annotation processing is
    +disabled using the \f[B]\f[VB]-proc:none\f[B]\f[R] option.
    +.PP
    +If annotation processing is requested, the compiler searches for any
     annotation processors that are available.
     The search path can be specified with the
     \f[B]\f[VB]-processorpath\f[B]\f[R] option.


Comments
Moving to Approved.
25-05-2024