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

Must declare classes to implement Serializable

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      A script like

      class C {
        int x
      }
      def c = new C()
      c.x = 5
      sh "echo ${c.x}"
      

      will fail since the local variable c is of a nonserializable type. You need to explicitly say

      class C implements Serializable {
      // ...
      

      Since groovy-cps demands that local variables may be serialized, any locally defined classes must also be serializable (unless they are only ever being passed to binary methods: legal but unlikely).

      Perhaps the transformer could implicitly add implements Serializable to any class declarations it finds. Generally this is harmless: if the class in fact contains some nonserializable fields, trying to serialize an instance will still fail in a predictable way.

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -
            Show
            abayer Andrew Bayer added a comment - groovy-cps PR up at https://github.com/cloudbees/groovy-cps/pull/71
            Hide
            abayer Andrew Bayer added a comment -

            Merged, should be in next groovy-cps (i.e., 1.20) and workflow-cps (i.e., 2.41) releases.

            Show
            abayer Andrew Bayer added a comment - Merged, should be in next groovy-cps (i.e., 1.20) and workflow-cps (i.e., 2.41) releases.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                jglick Jesse Glick
              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: