From Sam.Mesh at gmail.com Thu Oct 2 04:52:28 2025 From: Sam.Mesh at gmail.com (Sam.Mesh) Date: Wed, 1 Oct 2025 21:52:28 -0700 Subject: Effectively final requirement for local variable and method reference, as for lambda In-Reply-To: References: Message-ID: Hi Gavin, Thank you very much for your reply. The question arose from the confusion about usage of non effectively final variable in method expression. According to JLS, in lambda, the variable must be effectively final. Search in the internet finds "The JLS views method references as a specialized type of lambda expression". So, the variable in method reference should be also effectively final? It looks like no, because compilers allow such usage. I cannot find this requirement for method reference in JLS. So, though this looks counter intuitive (because method reference is a form of lambda), there is no such requirement for method reference. Could you please confirm this? And, maybe, provide reasons why this requirement exists for lambda. Why are the same reasons not applicable for method reference? Thanks, Sam On Tue, Sep 30, 2025 at 8:36?AM Gavin Bierman wrote: > Hi Sam, > > 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)? > > Thanks, > Gavin > > > On 27 Sep 2025, at 00:11, Sam.Mesh wrote: > > > > Dear JLS Team, > > > > Could you please advise whether in JLS there is effectively final > requirement for local variable and method reference, same as for lambda? > > > > Thanks, > > Sam > > -------------- next part -------------- An HTML attachment was scrubbed... URL: