Serialization
Mark Reinhold
mr at sun.com
Tue Dec 15 21:26:51 PST 2009
> Date: Mon, 14 Dec 2009 01:23:54 -0500
> From: Peter Jones <pcj at roundroom.net>
> I expect that there would be the issue that is also a problem with serializing
> instances of anonymous classes today: that the binary names of the classes are
> neither JLS-determined nor very stable across edits/recompiles. Serialization
> represents an object's code by its class's binary name, but these things won't
> have overt names. Moreover, the set of a closure's serializable fields seems
> likely to be less stable in practice compared to a normally-declared class.
> And I don't see how you could specify any of the usual customizations to
> serialized form or behavior (transient, readObject, etc.). What these issues
> suggest to me is that in cases where the writing and the reading code are from
> the exact same compilation of sources, then perhaps serialization of closures
> could work and be useful-- but I don't see it working in the more general case
> of communication across an API contract.
Like I said -- serialization is tricky. Thanks Peter.
Taken together these are good reasons not to make closures serializable,
at least not at the outset. If there turn out to be compelling use cases
then we could look in to making them serializable later on.
- Mark
More information about the lambda-dev
mailing list