Serialization opt-in syntax (summary)

David M. Lloyd david.lloyd at
Tue Oct 9 06:40:12 PDT 2012

On 10/09/2012 01:07 AM, Remi Forax wrote:
> We have several choices:
>   - use an annotation like @Serial, but currently there is no way o
> attach an annotation
>      to an expression, so this was rule out.
>   - use a cast to (Foo & Serializable) but the solution to allow users
> to use & to specify a type
>     is far from easy and require investigation and we haven't time for
> that.
> so if no one has a better idea, this means we need a ad-hoc syntax to
> specify that a lambda is serialize
> (David, users want to serialize capturing lambda).

Users also want the compiler to magically do what they mean, not what 
they say... but in the end the best thing we can do for users is make 
the rules simple and predictable.

> I think we have rule out to soon the fact that we also can use a
> specific syntax, perhaps not x ~> x or
> x -s> x (the snake arrow Josh had proposed) but a specific syntax is a
> ad-hoc solution too.

I don't think you are grasping how incredibly unstable it will be to 
serialize a capturing lambda, and the fact that we are more concerned 
about what (we are assuming) users (think they) want versus what we know 
will be very fragile is very worrisome to me.  I am certain that if we 
allow it as-is, it *will* impact the overall perception of stability of 
Java EE, which (like it or not) relies heavily upon serialization 
(including collections).

If we want to be able to support serializing capturing lambdas, they 
simply must have stable names, and their captured values must also have 
stable names; if we cannot do that then we simply cannot support it!


More information about the lambda-spec-experts mailing list