Effective finality requirements for method reference receiver ?

Brian Goetz brian.goetz at oracle.com
Thu Feb 14 08:01:01 PST 2013


> 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.)

> 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