Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8335404

javac implicit annotation processing warning should print processors

XMLWordPrintable

    • generic
    • generic

      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.




            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: