----- Mail original ----- > De: "Brian Goetz" <brian.go...@oracle.com> > À: "Peter Levart" <peter.lev...@gmail.com> > Cc: "amber-spec-experts" <amber-spec-experts@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. yes, an implicit extra component also doesn't play well with the pattern matching extraction. Rémi