Lambdas and serialization
alessiostalla at gmail.com
Tue Oct 19 15:33:33 PDT 2010
On Tue, Oct 19, 2010 at 7:18 PM, Bob Lee <crazybob at crazybob.org> wrote:
> FWIW, anonymous inner classes can technically be serializable (insofar as
> they can implement Serializable), but it's typically not safe to do so
> because their internal state is unspecified. In other words, the
> serializable form of an anonymous inner class from one compiler may not be
> compatible with another.
Well, but then the serializable form of any java.* class is not
necessarily compatible between different JVMs, again because the
internal details might be different. Default serialization is not
meant as a standard storage format, rather as a means to store a graph
of objects into a sequence of bytes and restore it later *using the
> I've personally always wanted anonymous classes to be safely serializable so
> I could use them in HTTP sessions, RPCs, etc.
If you want, you can; serialization is flexible enough to allow it.
Provided of course that both sides of the communication have loaded
the same class with the same name.
More information about the lambda-dev