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

Unable to build Jenkins with Java 8 set as target version

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • None
    • Jenkins 2.49, master as of 2017-03-12

      Playing with some Java 8 related improvements in Jenkins I've noticed that Jenkins cannot be built with Java 8 set as desired source/target level and it looks somehow tricky.

      [INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ jenkins-core ---
      [INFO] Changes detected - recompiling the module!
      [INFO] Compiling 1048 source files to /home/foo/Code/jenkins/core/target/classes
      [INFO] -------------------------------------------------------------
      [ERROR] COMPILATION ERROR :
      [INFO] -------------------------------------------------------------
      [ERROR] /home/foo/Code/jenkins/core/src/main/java/hudson/model/User.java:[658,22] error: method fromJobs in class RunList<R#2> cannot be applied to given types;
      [ERROR]   required: Iterable<? extends J#1>
        found: Iterable<Job>
        reason: inferred type does not conform to lower bound(s)
          inferred: J#2
          lower bound(s): T,Job
        where J#1,R#1,R#2,J#2,R#3,T are type-variables:
          J#1 extends Job<J#1,R#1> declared in method <J#1,R#1>fromJobs(Iterable<? extends J#1>)
          R#1 extends Run<J#1,R#1> declared in method <J#1,R#1>fromJobs(Iterable<? extends J#1>)
          R#2 extends Run declared in class RunList
          J#2 extends Job<J#2,R#3>
          R#3 extends Run<J#2,R#3>
          T extends J#2
      /home/foo/Code/jenkins/core/src/main/java/hudson/model/Computer.java:[781,22] error: method fromJobs in class RunList<R#2> cannot be applied to given types;
      [INFO] 2 errors
      [INFO] -------------------------------------------------------------
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary:
      [INFO]
      [INFO] Jenkins main module ................................ SUCCESS [  2.169 s]
      [INFO] Jenkins cli ........................................ SUCCESS [  3.655 s]
      [INFO] Jenkins core ....................................... FAILURE [ 35.684 s]
      [INFO] Jenkins war ........................................ SKIPPED
      [INFO] Tests for Jenkins core ............................. SKIPPED
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE

       Error can be reproduced in my branch.

      As migration to Java 8 is getting closer and closer it would be good to have it solved.

          [JENKINS-42709] Unable to build Jenkins with Java 8 set as target version

          Jesse Glick added a comment -

          Probably suffices to replace RunList.fromJobs with RunList.<Job<?,?>>fromJobs.

          Jesse Glick added a comment - Probably suffices to replace RunList.fromJobs with RunList.<Job<?,?>>fromJobs .

          Thanks a lot for the notice emszpak, you're right JDK8 upgrade is approaching so we want to have a look (though we can easily postpone if needed, no hard push here).

          If you don't feel like doing it, I will prepare a PR and work on it soon to have it ready for the bump. I thought that would just be a target/source bump, but apparently not .

          Thanks jglick for the hint.

          Baptiste Mathus added a comment - Thanks a lot for the notice emszpak , you're right JDK8 upgrade is approaching so we want to have a look (though we can easily postpone if needed, no hard push here). If you don't feel like doing it, I will prepare a PR and work on it soon to have it ready for the bump. I thought that would just be a target/source bump, but apparently not . Thanks jglick for the hint.

          batmat Feel free to take it. I'm currently working on some other PRs and will not come back to that Java 8 related very soon.

          Marcin Zajączkowski added a comment - batmat Feel free to take it. I'm currently working on some other PRs and will not come back to that Java 8 related very soon.

          I got past to the generics issue, but then I hit deeper issues related the bridge-method-injector maven plugin. Filed WIP PR https://github.com/jenkinsci/jenkins/pull/2802

          Baptiste Mathus added a comment - I got past to the generics issue, but then I hit deeper issues related the bridge-method-injector maven plugin. Filed WIP PR  https://github.com/jenkinsci/jenkins/pull/2802

          Code changed in jenkins
          User: Marcin Zajączkowski
          Path:
          pom.xml
          http://jenkins-ci.org/commit/jenkins/8ae105ef5f39837ebe38ca0720e1ec3799567947
          Log:
          JENKINS-42709 Unable to build for Java 8

          With Java 8 set as build target version.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marcin Zajączkowski Path: pom.xml http://jenkins-ci.org/commit/jenkins/8ae105ef5f39837ebe38ca0720e1ec3799567947 Log: JENKINS-42709 Unable to build for Java 8 With Java 8 set as build target version.

          Code changed in jenkins
          User: Baptiste Mathus
          Path:
          Jenkinsfile
          core/pom.xml
          core/src/build-script/Cobertura.groovy
          core/src/main/java/hudson/model/Computer.java
          core/src/main/java/hudson/model/User.java
          pom.xml
          test/pom.xml
          test/src/test/java/hudson/model/GetEnvironmentOutsideBuildTest.java
          test/src/test/java/jenkins/util/JenkinsJVMRealTest.java
          http://jenkins-ci.org/commit/jenkins/09cfe3bda60341edb07ade226e24196a3f875019
          Log:
          Merge pull request #2802 from batmat/JENKINS-42709

          JENKINS-27624JENKINS-42709 Bump Jenkins baseline to Java 8 minimum

          Compare: https://github.com/jenkinsci/jenkins/compare/df6528e23392...09cfe3bda603

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Baptiste Mathus Path: Jenkinsfile core/pom.xml core/src/build-script/Cobertura.groovy core/src/main/java/hudson/model/Computer.java core/src/main/java/hudson/model/User.java pom.xml test/pom.xml test/src/test/java/hudson/model/GetEnvironmentOutsideBuildTest.java test/src/test/java/jenkins/util/JenkinsJVMRealTest.java http://jenkins-ci.org/commit/jenkins/09cfe3bda60341edb07ade226e24196a3f875019 Log: Merge pull request #2802 from batmat/ JENKINS-42709 JENKINS-27624 JENKINS-42709 Bump Jenkins baseline to Java 8 minimum Compare: https://github.com/jenkinsci/jenkins/compare/df6528e23392...09cfe3bda603

          Fixed towards 2.54

          Baptiste Mathus added a comment - Fixed towards 2.54

            batmat Baptiste Mathus
            emszpak Marcin Zajączkowski
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: