Lambdas and serialization

Alessio Stalla alessiostalla at gmail.com
Tue Oct 19 08:06:34 PDT 2010


On Tue, Oct 19, 2010 at 4:48 PM, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
> On 19/10/10 15:13, Paul Benedict wrote:
>>
>> Does the SAM specification say anything about it must implement ALL
>> the interfaces in the SAM wrapp? Or is that simply not decided on yet?
>>
>
> There shouldn't be differences between an instance of a SAM type created
> using 'new' and another instance obtained via lambda conversion. Which
> means, if the SAM type S is serializable, so should be the instance of S
> obtained when SAM-converting a lambda expression to the target type S.
>
> The fact that this might be difficult to achieve should the translation
> strategy exploit method handles is something that can be regarded as an
> implementation problem, not a design one.

Right, that and your previous reply answer my question. FWIW,
serialization of closures is implementation-dependent, and often
unsupported, in Common Lisp too. In the context of Java I think this
aspect should be documented clearly by the implementation, because
serialization is not rarely used; for example putting lambdas as
callbacks in a HttpSession might not be a good idea...


More information about the lambda-dev mailing list