JEP proposed to target JDK 11: 323: Local-Variable Syntax for Lambda Parameters
Florian Weimer
fweimer at redhat.com
Fri Jan 26 14:29:36 UTC 2018
On 01/26/2018 10:59 AM, Zheka Kozlov wrote:
> The motivation is to allow `final` and annotations on lambda parameters:
>
> (final var x) → x + 1;
> (@Nonnull var x) → x + 1;
>
> This is impossible to write with an implicitly typed lambda:
>
> (final x) → x + 1; // Illegal
> (@Nonnull x) → x + 1; // Illegal
Is this a useful feature? Either the annotation can be inferred from
the context, or it does not matter at all (it cannot be checked at run
time due to erasure).
Based on the follow-ups, it's not clear whether this is supposed to
apply to the method argument or a type parameter. Syntactically, I
would expect it to apply to the method argument.
Thanks,
Florian
More information about the jdk-dev
mailing list