Must declare classes to implement Serializable

This issue is archived. You can view it, but you can't modify it. Learn more

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.

            Assignee:
            Andrew Bayer
            Reporter:
            Jesse Glick
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: