Draft JLS spec for records - local types

Remi Forax forax at univ-mlv.fr
Sun Oct 6 15:29:44 UTC 2019

----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Peter Levart" <peter.levart at gmail.com>
> Cc: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Dimanche 6 Octobre 2019 17:06:14
> Objet: Re: Draft JLS spec for records - local types

>> When reading the spec, the following caught my attention:
>> """A nested record type is implicitly static. It is permitted for the
>> declaration of a nested record type to redundantly specify the static
>> modifier.
>>    This implies that it is impossible to declare a record type in the body of
>> an inner class (8.1.3), because an inner class cannot have static members
>> except for constant variables.
> Sharp eye!
> Yes, this is sad.  There are three ways to go:
> - Don’t make records implicitly static.
> - Allow static members in inner classes.
> - Don’t allow records in inner classes, at least for now, and do one of the
> others later.
> I don’t like the first one; inner records violate the spirit of records, which
> is their entire representation, API, and behavior is derived from their state
> descriptor.  An inner record would have a hidden extra component, and this
> would raise uncomfortable questions like “how does it play into the equally
> calculation.”  Better to say records are what they look like, which makes them
> implicitly static.

an implicit extra component also doesn't play well with the pattern matching extraction.


More information about the amber-spec-experts mailing list