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

Static initializers not allowed to set final fields

      The following code causes the script security plugin to fail with an ExceptionInInitializerError:

      class C {
          private final static boolean initialized;
          static { initialized = true }
      }
      

      The attached patch file adds testcases to SandboxInterceptorTest that shows this failure (and that setting the field using a field initializer and setting a non-final field via a static initalizer works)

          [JENKINS-34599] Static initializers not allowed to set final fields

          Andrew Bayer added a comment -

          Possibly related to JENKINS-45446?

          Andrew Bayer added a comment - Possibly related to JENKINS-45446 ?

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java
          http://jenkins-ci.org/commit/script-security-plugin/f5d212851c071de2355dca4aebcf3425537ae3d9
          Log:
          JENKINS-34599 Reproduced issues in test.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java http://jenkins-ci.org/commit/script-security-plugin/f5d212851c071de2355dca4aebcf3425537ae3d9 Log: JENKINS-34599 Reproduced issues in test.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java
          http://jenkins-ci.org/commit/script-security-plugin/c9b8c501de5a4555a445d0af7595695defc47ed2
          Log:
          [FIXED JENKINS-34599] Integrating fix.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java http://jenkins-ci.org/commit/script-security-plugin/c9b8c501de5a4555a445d0af7595695defc47ed2 Log: [FIXED JENKINS-34599] Integrating fix.

          Jesse Glick added a comment -

          Fixed, awaiting release.

          Jesse Glick added a comment - Fixed, awaiting release.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/f9ddb9279fe0a2f94a832837cd226f9974d7a684
          Log:
          JENKINS-34599 Demonstrating that fix also works in CPS mode.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/f9ddb9279fe0a2f94a832837cd226f9974d7a684 Log: JENKINS-34599 Demonstrating that fix also works in CPS mode.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/ebd87bb3e42318e3f0d8a68d00529999fd2fa248
          Log:
          Merge pull request #157 from jglick/final-fields-JENKINS-34599

          JENKINS-34599 JENKINS-45629 Demonstrating fixes

          Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/bcca2269e873...ebd87bb3e423

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/ebd87bb3e42318e3f0d8a68d00529999fd2fa248 Log: Merge pull request #157 from jglick/final-fields- JENKINS-34599 JENKINS-34599 JENKINS-45629 Demonstrating fixes Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/bcca2269e873...ebd87bb3e423

            jglick Jesse Glick
            magnusr Magnus Reftel
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: