Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-11739

Mysterious FilerException: Attempt to reopen a file for path ...

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None

      There was a report indicating that a compilation error happens while building Jenkins:

      [INFO] Copying 2 resources
      [INFO] [stapler:apt-compile {execution: default-apt-compile}]
      [INFO] Compiling 721 source files to /«PKGBUILDDIR»/core/target/classes
      [INFO]
      - ------------------------------------------------------------------------
      [ERROR] BUILD FAILURE
      [INFO]
      - ------------------------------------------------------------------------
      [INFO] Compilation failure
      
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path TemporarySpaceMonitor.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path CommandConnector.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path BuildButtonColumn.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path LastSuccessColumn.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path ListView.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path MavenInstallation.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path MavenInstaller.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path Maven.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path AbstractDiskSpaceMonitor.stapler
      

      To the best of my understanding, this can only happen if our annotation processors are invoked twice with the same set of root elements, and if I'm reading it right, with JSR-269 this cannot happen.

      Since blaming JSR-269 implementation will likely take years to resolve, I'm going ahead to work around this on our side. But to make sure that I'm not mis-interpreting JSR-269 or that there's something more deeper, I'm creating this ticket to solicit feedbacks from people.

          [JENKINS-11739] Mysterious FilerException: Attempt to reopen a file for path ...

          I've worked around this problem in Stapler 1.175 by simply ignoring this problem. But the error message points people to this ticket.

          Folks, if you see the message and come here, please report your exact JDK version, and verify if you continue to see the problem after a clean rebuild.

          Kohsuke Kawaguchi added a comment - I've worked around this problem in Stapler 1.175 by simply ignoring this problem. But the error message points people to this ticket. Folks, if you see the message and come here, please report your exact JDK version, and verify if you continue to see the problem after a clean rebuild.

          James Page found out that the root cause of this is old Jenkins core + new stapler combination, which causes both APT annotation processor and JSR-269 annotation processor to run.

          Kohsuke Kawaguchi added a comment - James Page found out that the root cause of this is old Jenkins core + new stapler combination, which causes both APT annotation processor and JSR-269 annotation processor to run.

          Actually, even with the correct matching versions, you can have this issue on

          Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
          Java version: 1.6.0_29, vendor: Apple Inc.
          Default locale: en_US, platform encoding: MacRoman
          OS name: "mac os x", version: "10.6.8", arch: "x86_64", family: "mac"

          at least.

          To reproduce, just put a package-info.java file in any directory with a @DataBoundConstructor

          Workaround to fix:

          remove the package-info.java file

          Happens with

          hpi 1.78 & stapler 1.16 (current head circa 1.449)
          hpi 1.74 & stapler 1.15 (1.424 LTS)
          hpi 1.71 & stapler 1.15 (1.409 LTS)

          Stephen Connolly added a comment - Actually, even with the correct matching versions, you can have this issue on Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000) Java version: 1.6.0_29, vendor: Apple Inc. Default locale: en_US, platform encoding: MacRoman OS name: "mac os x", version: "10.6.8", arch: "x86_64", family: "mac" at least. To reproduce, just put a package-info.java file in any directory with a @DataBoundConstructor Workaround to fix: remove the package-info.java file Happens with hpi 1.78 & stapler 1.16 (current head circa 1.449) hpi 1.74 & stapler 1.15 (1.424 LTS) hpi 1.71 & stapler 1.15 (1.409 LTS)

          Jesse Glick added a comment -

          Same happens (but with no workaround) in 1.466.1 when processing Plugin declarations, just running javac (i.e. APT is not to blame):

          at com.sun.tools.javac.processing.JavacFiler.checkFileReopening(JavacFiler.java:535)
          at com.sun.tools.javac.processing.JavacFiler.createResource(JavacFiler.java:431)
          at jenkins.PluginSubtypeMarker.write(PluginSubtypeMarker.java:99)
          at jenkins.PluginSubtypeMarker.access$100(PluginSubtypeMarker.java:60)
          at jenkins.PluginSubtypeMarker$1.visitType(PluginSubtypeMarker.java:71)
          at jenkins.PluginSubtypeMarker$1.visitType(PluginSubtypeMarker.java:64)
          at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:892)
          at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:141)
          at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:131)
          at javax.lang.model.util.ElementScanner6.visitPackage(ElementScanner6.java:160)
          at com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:692)
          at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:141)
          at jenkins.PluginSubtypeMarker.process(PluginSubtypeMarker.java:85)
          

          Jesse Glick added a comment - Same happens (but with no workaround) in 1.466.1 when processing Plugin declarations, just running javac (i.e. APT is not to blame): at com.sun.tools.javac.processing.JavacFiler.checkFileReopening(JavacFiler.java:535) at com.sun.tools.javac.processing.JavacFiler.createResource(JavacFiler.java:431) at jenkins.PluginSubtypeMarker.write(PluginSubtypeMarker.java:99) at jenkins.PluginSubtypeMarker.access$100(PluginSubtypeMarker.java:60) at jenkins.PluginSubtypeMarker$1.visitType(PluginSubtypeMarker.java:71) at jenkins.PluginSubtypeMarker$1.visitType(PluginSubtypeMarker.java:64) at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:892) at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:141) at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:131) at javax.lang.model.util.ElementScanner6.visitPackage(ElementScanner6.java:160) at com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:692) at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:141) at jenkins.PluginSubtypeMarker.process(PluginSubtypeMarker.java:85)

          Jesse Glick added a comment -

          The processor is not really written correctly; the right way to write processors which generate an index is to read the existing file, if any, queue up writes while !processingOver, then when processingOver perform them (unless errorRaised). org.openide.util.lookup.implspi.AbstractServiceProviderProcessor is an example. But the immediate bug is triggered, as Stephen found, by package-info.java since you are incorrectly scanning package elements.

          Jesse Glick added a comment - The processor is not really written correctly; the right way to write processors which generate an index is to read the existing file, if any, queue up writes while !processingOver , then when processingOver perform them (unless errorRaised ). org.openide.util.lookup.implspi.AbstractServiceProviderProcessor is an example. But the immediate bug is triggered, as Stephen found, by package-info.java since you are incorrectly scanning package elements.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/main/java/jenkins/PluginSubtypeMarker.java
          http://jenkins-ci.org/commit/jenkins/88b613e95f6d8991a047f13275179e190e4c7587
          Log:
          JENKINS-11739 Cannot compile a plugin with a Plugin subclass in the same package as a package-info.java.
          (Not quite FIXED yet since org.kohsuke.stapler.jsr269 seems to suffer from a similar bug, currently printing ugly warnings.)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/jenkins/PluginSubtypeMarker.java http://jenkins-ci.org/commit/jenkins/88b613e95f6d8991a047f13275179e190e4c7587 Log: JENKINS-11739 Cannot compile a plugin with a Plugin subclass in the same package as a package-info.java. (Not quite FIXED yet since org.kohsuke.stapler.jsr269 seems to suffer from a similar bug, currently printing ugly warnings.)

          dogfood added a comment -

          Integrated in jenkins_main_trunk #1829
          JENKINS-11739 Cannot compile a plugin with a Plugin subclass in the same package as a package-info.java. (Revision 88b613e95f6d8991a047f13275179e190e4c7587)

          Result = UNSTABLE
          Jesse Glick : 88b613e95f6d8991a047f13275179e190e4c7587
          Files :

          • core/src/main/java/jenkins/PluginSubtypeMarker.java

          dogfood added a comment - Integrated in jenkins_main_trunk #1829 JENKINS-11739 Cannot compile a plugin with a Plugin subclass in the same package as a package-info.java. (Revision 88b613e95f6d8991a047f13275179e190e4c7587) Result = UNSTABLE Jesse Glick : 88b613e95f6d8991a047f13275179e190e4c7587 Files : core/src/main/java/jenkins/PluginSubtypeMarker.java

          Jesse Glick added a comment -

          Final fix is in Stapler, but I did not manage to release it.

          Jesse Glick added a comment - Final fix is in Stapler, but I did not manage to release it.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          changelog.html
          core/pom.xml
          war/pom.xml
          http://jenkins-ci.org/commit/jenkins/10dddebf7bd86e30b630038e5ebe0295f190a8de
          Log:
          [FIXED JENKINS-11739] Various mistakes in annotation processors affecting some plugins.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: changelog.html core/pom.xml war/pom.xml http://jenkins-ci.org/commit/jenkins/10dddebf7bd86e30b630038e5ebe0295f190a8de Log: [FIXED JENKINS-11739] Various mistakes in annotation processors affecting some plugins.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #1836
          [FIXED JENKINS-11739] Various mistakes in annotation processors affecting some plugins. (Revision 10dddebf7bd86e30b630038e5ebe0295f190a8de)

          Result = UNSTABLE
          Jesse Glick : 10dddebf7bd86e30b630038e5ebe0295f190a8de
          Files :

          • core/pom.xml
          • changelog.html
          • war/pom.xml

          dogfood added a comment - Integrated in jenkins_main_trunk #1836 [FIXED JENKINS-11739] Various mistakes in annotation processors affecting some plugins. (Revision 10dddebf7bd86e30b630038e5ebe0295f190a8de) Result = UNSTABLE Jesse Glick : 10dddebf7bd86e30b630038e5ebe0295f190a8de Files : core/pom.xml changelog.html war/pom.xml

            kohsuke Kohsuke Kawaguchi
            kohsuke Kohsuke Kawaguchi
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: