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

Must declare classes to implement Serializable

XMLWordPrintable

      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.

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

              Created:
              Updated:
              Resolved: