Annotations on lambda parameters and captured outer locals.

Alex Buckley alex.buckley at oracle.com
Thu Dec 3 23:23:10 UTC 2015


On 12/2/2015 9:28 PM, Srikanth wrote:
> The prose in the description of JDK-8138729 read in conjunction with
> JDK-8140279 would seem to require that
>
>      - Declaration and type annotations from the captured outer locals
> of a lambda
>        expression are not to be transmitted to the formal parameter
> (that represents/reifies
>        the captured local variable) of the synthetic lambda
> implementation method[*]

Yes. No-one should be relying on any aspect of this formal parameter. 
Transmitting declaration annotations to it, or type annotations to its 
type, would be an attractive nuisance.

>      - Declaration annotations on a lambda formal should not make it to the
>        class file at all.

Yes. The true intent of JSR 335 was that declaration annotations on a 
lambda formal should be source-only, like declaration annotations on a 
local variable. JLS9 will clarify this, via JDK-8140279.

>      - Type annotations on the type of a lambda formal should be carried
> over to the type
>        of the formal parameter of the synthetic method that implements
> the lambda[*]

Yes. Specifically on this point, Brian said "I'm OK that type 
annotations travel with their type uses, because dataflow analysis can 
still be useful against such classfiles (which was the point of type 
annos) without turning this into a metaprogramming framework."

Alex


More information about the compiler-dev mailing list