<div dir="ltr">Hi Gavin,<div><br></div><div>Thank you very much for your reply.</div><div><br></div><div>The question arose from the confusion about usage of non effectively final variable in method expression.</div><div><br></div><div>According to JLS, in lambda, the variable must be effectively final.</div><div><br></div><div>Search in the internet finds "The JLS views method references as a specialized type of lambda expression".</div><div><div>So, the variable in method reference should be also effectively final?</div><div><br></div><div>It looks like no, because compilers allow such usage.</div><div><br></div></div><div>I cannot find this requirement for method reference in JLS.</div><div>So, though this looks counter intuitive (because method reference is a form of lambda), there is no such requirement for method reference. </div><div><br></div><div>Could you please confirm this?</div><div><br></div><div>And, maybe, provide reasons why this requirement exists for lambda.</div><div>Why are the same reasons not applicable for method reference?</div><div><br></div><div>Thanks,</div><div>Sam</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Sep 30, 2025 at 8:36 AM Gavin Bierman <<a href="mailto:gavin.bierman@oracle.com">gavin.bierman@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Sam,<br>
<br>
This mail alias is for reporting technical errors and ambiguities in the JLS. I’m not sure that I understand your email I’m afraid. Are you suggesting that there is a problem with the specification regarding effectively final variables (4.12.4) or around the requirement that any local variable, formal parameter, or exception parameter used but not declared in a lambda expression must either be final or effectively final (15.27.2)?<br>
<br>
Thanks,<br>
Gavin<br>
<br>
> On 27 Sep 2025, at 00:11, Sam.Mesh <<a href="mailto:Sam.Mesh@gmail.com" target="_blank">Sam.Mesh@gmail.com</a>> wrote:<br>
> <br>
> Dear JLS Team,<br>
> <br>
> Could you please advise whether in JLS there is effectively final requirement for local variable and method reference, same as for lambda?<br>
> <br>
> Thanks,<br>
> Sam<br>
<br>
</blockquote></div>