Serialization opt-in syntax (summary)
forax at univ-mlv.fr
Tue Oct 9 05:12:11 PDT 2012
On 10/09/2012 12:23 PM, Ali Lahijani wrote:
> On Tue, Oct 9, 2012 at 9:37 AM, Remi Forax <forax at univ-mlv.fr> wrote:
>> We have several choices:
>> - use an annotation like @Serial, but currently there is no way o attach an
>> 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.
yes, it's a good fallback solution if we don't find a way to specify
that the lambda should be serializable without repeating the target type.
More information about the lambda-spec-observers