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

Filer should warn if processors redefine symbols from the classpath or sourcepath

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 11
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Minor behavioral compatibility hazard to those intentionally running with annotation processor lint warnings enabled and configurations flagged by the new check.
    • Interface Kind:
      Java API
    • Scope:
      JDK

      Description

      Summary

      Have javac emit a warning if -Xlint:processing is enabled and an annotation processor defines a symbol that was already present on the sourcepath or classpath.

      Problem

      Redefining symbols during annotation processing could result in multiple incompatible definitions of the symbol being observed during the compilation, which could cause incorrect behaviour.

      Solution

      Emit a lint warning to alert developers to the problem.

      Specification

      The existing specification of -Xlint:processing is that it "warns about the issues related to annotation processing". This issue is in that category.

      The existing specification of javax.annotation.processing.Filer places some restrictions on generating duplicate or conflicting files. It does not discuss situations where a filer implementation might emit warnings.

      During each run of an annotation processing tool, a file with a given pathname may be created only once. If that file already exists before the first attempt to create it, the old contents will be deleted. Any subsequent attempt to create the same file during a run will throw a FilerException, as will attempting to create both a class file and source file for the same type name or same package name. The initial inputs to the tool are considered to be created by the zeroth round; therefore, attempting to create a source or class file corresponding to one of those inputs will result in a FilerException.

      In general, processors must not knowingly attempt to overwrite existing files that were not generated by some processor. A Filer may reject attempts to open a file corresponding to an existing type, like java.lang.Object. Likewise, the invoker of the annotation processing tool must not knowingly configure the tool such that the discovered processors will attempt to overwrite existing files that were not generated.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cushon Liam Miller-Cushon
                Reporter:
                cushon Liam Miller-Cushon
                Reviewed By:
                Joe Darcy
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: