Local classes and static members?

Remi Forax forax at univ-mlv.fr
Sat Jun 15 06:01:21 UTC 2024


> From: "Archie Cobbs" <archie.cobbs at gmail.com>
> To: "amber-spec-experts" <amber-spec-experts at openjdk.org>
> Sent: Saturday, June 15, 2024 12:50:13 AM
> Subject: Re: Local classes and static members?

> Answering my own question...

> It's a dumb question because it's no longer true. Originally local classes could
> not have static members but that changed in JDK 16 with [
> https://bugs.openjdk.org/browse/JDK-8254321 | JDK-8254321 ] .

yes, 
at the time records were introduced. 

The only missing related feature is to allow the keyword 'static' in front of a local class, which is useful when you want to sandbox a static local class into a method by example in unit tests. 

> -Archie

Rémi 

> On Fri, Jun 14, 2024 at 3:52 PM Archie Cobbs < [ mailto:archie.cobbs at gmail.com |
> archie.cobbs at gmail.com ] > wrote:

>> Dumb question...

>> Where is it specified in the JLS that a (normal) local class cannot have static
>> members? I don't see it in [
>> https://docs.oracle.com/javase/specs/jls/se22/html/jls-14.html#jls-14.3 | §14.3
>> ] .

>> Thanks.

>> --
>> Archie L. Cobbs

> --
> Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20240615/0fb067ed/attachment.htm>


More information about the amber-spec-experts mailing list