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

Static initializers not allowed to set final fields

    XMLWordPrintable

Details

    Description

      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)

      Attachments

        Issue Links

          Activity

            abayer Andrew Bayer added a comment -

            Possibly related to JENKINS-45446?

            abayer 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_issue_link 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_issue_link 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.
            jglick Jesse Glick added a comment -

            Fixed, awaiting release.

            jglick 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_issue_link 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_issue_link 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

            People

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

              Dates

                Created:
                Updated:
                Resolved: