JDK-8315534 : Incorrect warnings about implicit annotation processing
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 21
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-09-01
  • Updated: 2023-09-07
  • Resolved: 2023-09-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 22
21.0.1Fixed 22 b14Fixed
Related Reports
Relates :  
Description
Consider code like:
---
                com.sun.source.util.JavacTask task =
                        (com.sun.source.util.JavacTask) provider.getTask(compilerOut, null, null, options, null, inputFile);

                Processor processor =
                        (Processor) processorClass.getDeclaredConstructor().newInstance();

                task.setProcessors(List.of(processor));
                task.analyze();
---

This will produce warning like:
---
Note: 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.
---

which is incorrect, as the processors where passed in using the API.

Comments
Fix Request javac is producing a warning about implicit annotation processing. It should not produce the warnings, as the AP was requested explicitly. The fix simply moves the detection of explicit annotation processing to a more general location, and should generally be safe. Standard javac tests are passing.
04-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/132 Date: 2023-09-04 10:41:43 +0000
04-09-2023

Changeset: 94a74a0a Author: Jan Lahoda <jlahoda@openjdk.org> Date: 2023-09-04 10:06:20 +0000 URL: https://git.openjdk.org/jdk/commit/94a74a0a450cad6080302bc1db15a1a564940bdd
04-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15540 Date: 2023-09-01 15:44:06 +0000
01-09-2023