Serialization opt-in syntax (summary)

Ali Lahijani alahijani at
Tue Oct 9 03:23:05 PDT 2012

On Tue, Oct 9, 2012 at 9:37 AM, Remi Forax <forax at> 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).

What about a blend of the two? If target typing for intersection types
is workable in principle, it should also be sound with type

Predicate<String> foo = (@Serial Predicate<String>) (s) -> s.isEmpty();

Arguably, annotated casts are already a full expression-annotation
mechanism in Java, unless you are willing to shut down some essential
parts of JSR 308.


More information about the lambda-spec-observers mailing list