recursive lambda as a local variable

Brian Goetz brian.goetz at oracle.com
Fri Sep 13 07:15:00 PDT 2013


 From a pure implementation perspective, it could be done in either 
place.  We'd have to spec that the MF has this behavior, and either add 
a flag that says "first argument is bound receiver", or spec that we 
infer a bound receiver for invoke{virtual,interface,special} method 
handles with a non-zero bound argument count.

 From a spec-compliance perspective, it seems to make more sense for the 
compiler to do it.

On 9/13/2013 4:21 AM, Peter Levart wrote:
>
> On 09/12/2013 05:17 PM, Brian Goetz wrote:
>>> - The part left of the '::' can be an arbitrarily long expression that will
>>> be evaluated immediately, while the method invocation itself will be
>>> deferred until the corresponding SAM method is invoked. Thus, 'null' might
>>> by bound now and detected much later.
>> This is just a compiler bug; if the part to the left evaluates to null,
>> it should throw NPE immediately (see jsr335-15.28.2-30-A2: If the result
>> of evaluation of the subexpression is null, then a NullPointerException
>> is thrown.)
>>
>> Thanks for reporting this.  I will file a bug.
>
> This could be checked in lambda metafactory generated constructor,
> right? It doesn't have to be compiler generated code.
>
> Regards, Peter
>
>>
>


More information about the lambda-dev mailing list