Effective finality requirements for method reference receiver ?

Remi Forax forax at univ-mlv.fr
Thu Feb 14 11:55:19 PST 2013


On 02/14/2013 05:01 PM, Brian Goetz wrote:
>> Are there any ?
>
> No.  As part of evaluating a method reference, the receiver is 
> evaluated.  So it is fine to have a mutable receiver; the value is 
> bound at the time the MR is evaluated.  Then the receiver is treated 
> as the first captured argument and placed in the dynamic argument list 
> of the metafactory (pushed on the stack for the indy call.)

You can use the very same argument for captured local variable of 
lambda/inner class if there are not mutated inside the lambda/inner-class.

Rémi

>
>> 0.6.1 - Part C is silent. The words final and capture don't occur there.
>> But SOTL 4th edition talks about the implicit lambda capturing a 
>> variable
>> and using that as the receiver. Spec should override all other prose -
>> right ?
>> I also see that the mention of implicit lambda is from a pedagogical 
>> pov.
>>
>> BTW, 0.6.1 Part B links to SOTL edition 3 - which is very outdated with
>> respect
>> to the present state of affairs.
>>
>> I see that javac 8b74 compiles this code fine:
>>
>> // --
>> interface I {
>>          void foo();
>> }
>>
>> public class X {
>>          private void foo() {
>>      X x = new X();
>>      x = new X();
>>      I i = x::foo;
>>          }
>> }
>>
>> Thanks in advance for any clarifications.
>> Srikanth.



More information about the lambda-spec-observers mailing list