Draft JLS spec for records

forax at univ-mlv.fr forax at univ-mlv.fr
Thu Sep 5 22:07:27 UTC 2019

----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "John Rose" <john.r.rose at oracle.com>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Jeudi 5 Septembre 2019 23:48:08
> Objet: Re: Draft JLS spec for records

>> It's not what i'm saying.
> Maybe you could tell us what you are saying?

from the same mail:
"the canonical constructor should follow the same rule as the default constructor".

record Bar { } // the constructor is public, it's a top level record

class Foo {
  private record Bar(int x)  {} // the constructor is private, internal class has their canonical constructor with the same visibility as the record itself

interface Foo {
  record Bar(int x) {}  // the constructor is public, because inside an interface members are public by default

and you have not answer to:
Also why having the constructor public helps to make the record instantiatable, a constructor to be accessible by reflection requires that both the class and the constructor to be public. So following your point, does it means that all record have to be public too ?


More information about the amber-spec-observers mailing list