JDK-8335404 : javac implicit annotation processing warning should print processors
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2024-06-26
  • Updated: 2024-07-29
Related Reports
Relates :  
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
Relates to JDK-8306819, JDK-8310061

# Problem
Currently the implicit annotation processing warning emitted for JDK 21 just prints *that* annotation processors were found. However, it does not print *which* were found.
This makes it difficult for users to react to this warning, especially when using lots of dependencies and it is not clear which contains an annotation processor and whether it is relevant. So users might just use `-proc:full` for simplicity which might defeat the purpose of the warning because it does raise more awareness, or users might use `-proc:none` and try to find the relevant annotation processor (if any) through trial and error.

For example Log4j 2 has the processor `PluginProcessor` which many users might have on their classpath because it is not in a separate artifact, but most users don't actually rely on it. But they will nonetheless see the javac warning and it might not be obvious that Log4j 2's class is causing this.


# Suggested solution
It seems `com.sun.tools.javac.processing.JavacProcessingEnvironment#atLeastOneProcessor` already has the information about the processors.
Ideally the warning would include the full class names of all processors, and maybe also the code source (e.g. JAR location) if possible. This then at least gives a hint to the user which artifact contains the annotation processor and whether they actually rely on it.

Maybe also for future JDK versions for users of `-proc:full` or `-processorpath` it would be useful if there was an additional opt-in way to print all discovered annotation processors. (Unless this feature already exists, but at least it does not seem to be mentioned in the "Annotation Processing" section of the `javac` documentation.)

# Workaround
Run `javac` with remote debugging, e.g. when used with Maven by running `mvnDebug test`.
Then in your IDE attach the debugger and set a breakpoint in `com.sun.tools.javac.processing.JavacProcessingEnvironment#atLeastOneProcessor` and once the breakpoint is hit, evaluate `discoveredProcs.iterator()` and look at the `ProcessorState#processor` values of the elements.





Comments
Not an unreasonable suggestion. Partial information would be printed using existing flags by using the "-XprintProcessorInfo" javac option; although there are cases that may not display all the information of interest.
02-07-2024

Moving to JDK for further evaluation.
01-07-2024