Hi all,

I was looking into various uses of Groovy that require serialization of the
underlying library classes (for example, Spark, etc) and found that one of
the road blocks is that the built in IntRange class isn't serializable.

For example, this test fails:

    new File('test.ser').withObjectOutputStream { oos ->
oos.writeObject(1..10) } // Exception

With
java.io.NotSerializableException: groovy.lang.IntRange
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)

I played around a bit to see if it can be made serializable by extending
the class, but it turns out that doesn't work either because a class can
only be made serializable if its parent is either serializable itself OR if
it defines a default constructor (not true of IntRange).

So this is to ask, while 3.0 is still in the beta stage, would it be viable
to consider either adding a default constructor to IntRange (could be
protected), or actually making it serializable?

Otherwise quite a lot of Groovy code can't be used in places where
serializability is a requirement!

Cheers,

Simon

Reply via email to