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

EnvInject plugin doesn't work on JDK 12+

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • envinject-plugin
    • Server:
      Debian 10 x64
      OpenJDK 11 (build 11.0.12+7-post-Debian-2deb10u1)
      Jenkins 2.303.2
      EnvInject plugin 2.4.0

      Agent:
      macOS Big Sur 11.6 x64
      OpenJDK 15 (build 15+36-1562)
    • 2.875.v9b_9e962da_a_ec

      https://github.com/jenkinsci/envinject-plugin/blob/f72ef372efdef8791a175f1c121e067c10da40a6/src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectMasterEnvVarsSetter.java#L35 uses Field.class.getDeclaredField("modifiers") to remove the "final" modifier from the static field EnvVars.masterEnvVars (https://github.com/jenkinsci/jenkins/blob/f23512f2bc97d18cd4f0183a7db4a62bc6b84196/core/src/main/java/hudson/EnvVars.java#L459). This method is no longer working on OpenJDK 12+.

      According to https://bugs.openjdk.java.net/browse/JDK-8217225?focusedCommentId=14237541&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14237541:

      The change in JDK 12 is intentional to improve the robustness and security of the platform. In general, there is no supported way to change static final fields.

      This error can be seen in the logs as:

      onOnline: class org.jenkinsci.plugins.envinject.EnvInjectComputerListener reported an exception: java.io.IOException: org.jenkinsci.lib.envinject.EnvInjectException: java.lang.NoSuchFieldException: modifiers

            Unassigned Unassigned
            ngg Gergely Nagy
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: