> De: "Gavin Bierman" <gavin.bier...@oracle.com> > À: "Remi Forax" <fo...@univ-mlv.fr> > Cc: "Brian Goetz" <brian.go...@oracle.com>, "amber-spec-experts" > <amber-spec-experts@openjdk.java.net> > Envoyé: Mardi 3 Septembre 2019 12:37:17 > Objet: Re: Draft JLS spec for records
> Thanks Remi. >> - a canonical constructor can not have throws clause (from the text of the >> section) but the grammar in 8.10.2 the CompactConstructor declaration can >> have >> a throw clause ? > That is just a typo - thanks. The rest I will get back to you shortly. humm, thinking more about the canonical constructor - does'nt really need a modifier (it's always public if you believe the current state of the spec or it's the one of the record anyway) - doesn't need to declare a type parameter - doesn't need annotations because you get the one from the record so it's more like an initializer than a constructor. Given that i've always find the syntax of the canonical constructor too close to the one of the real constructor (depending on the fact that parenthesis are present or not), i propose a new kind of initializer, the require initializer (obvisouly it can be another name than "require"). An example of syntax: record Foo(String s) { require { Objects.requireNonNull(s); } } I also believe we should make the instance initializer illegal in record given that a require initializer is a kind a better instance initializer because it can access local variables. An example that should not compile record Foo(String s) { require { System.out.println("am i print first ?"); } { System.out.println("am i print first ?"); } } > Thanks, > Gavin Rémi