+1 - I like this. We now define precisely what an accessor and a
canonical constructor are - and then rule some of the explicit
declarations out, with no room for ambiguities.
Great job.
Maurizio
On 25/11/2019 23:50, Brian Goetz wrote:
The approach is much improved. I like that it casts a wide net for things that
could be confused for a canonical ctor / accessor, and then nails down
conditions for its correctness, rather than trying to do both in one go — and
letting some error cases risk falling through the cracks. It also means it is
easier to fine-tune the restrictions on exact type matches or accessibility or
whatever. So +1.
I also like that it gives accessor a standing in the language, which will be
useful later when we get to deconstruction patterns, for example.
On Nov 25, 2019, at 6:23 PM, Gavin Bierman <gavin.bier...@oracle.com> wrote:
A further updated draft language spec for JEP 359 (Records) is available at:
http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191125/specs/records-jls.html
along with an updated JVMS spec:
http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191125/specs/records-jvms.html
(Thanks to Maurizio, Alex, Tagir and others for feedback.)
Main change is around the definition of canonical constructor and accessor
methods. The text has changed quite a bit, but this is mainly at the surface.
Hopefully this new definition is easier to understand than before and removes
some corner cases (most of which were of the “which error should arise from
this program?”).
The idea for canonical constructors is as follows (it’s very similar for
accessor methods): You are a constructor. If your signature is
override-equivalent to the constructor signature derived from the record
declaration in the obvious way, then you are considered a canonical
constructor. (This also means that there can’t be more than one canonical
constructor.) In addition, as you have been identified as a canonical
constructor, you must satisfy some additional requirements, otherwise there is
a compile-time error. These are:
The types of the formal parameters in the formal parameter list of the
canonical constructor must be identical to the declared type of the
corresponding record component.
A canonical constructor must not be generic (8.8.4).
A canonical constructor must be declared public.
A canonical constructor must not have a throws clause.
The body of a canonical constructor must not contain an explicit constructor
invocation statement (8.8.7.1).
All the other rules for a constructor in a normal class declaration must be
satisfied (8.8).
We could relax some of these rules - I know Remi would like to change the third
one :-) The first one is another candidate. I propose that we try these ones
out in the preview, and during the preview period you can send us your
experience kicking the tires with these. [One reason for this refactoring is
that should we decide to relax some of these restrictions, it is a relatively
simple change to the spec, which will make our lives easier for subsequent
JDKs.]
Many thanks,
Gavin
On 21 Nov 2019, at 15:01, Gavin Bierman <gavin.bier...@oracle.com> wrote:
A hopefully final draft language spec for JEP 359 (Records) is available at:
http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191121/specs/records-jls.html
<http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191121/specs/records-jls.html>
This incorporates (I hope!) all the very helpful suggestions from everyone on
these lists - many thanks.
As always - any further comments/thoughts/bugs most welcome!
Gavin
On 31 Oct 2019, at 14:17, Gavin Bierman <gavin.bier...@oracle.com
<mailto:gavin.bier...@oracle.com>> wrote:
An updated draft language spec for JEP 359 (Records) is available at:
http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191031/specs/records-jls.html
<http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191031/specs/records-jls.html>
(Alongside is a draft JVM spec for this feature:
http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191031/specs/records-jvms.html
<http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191031/specs/records-jvms.html>
)
As always, please email me any comments/thoughts/bugs.
Thanks,
Gavin
On 23 Aug 2019, at 22:25, Gavin Bierman <gavin.bier...@oracle.com
<mailto:gavin.bier...@oracle.com>> wrote:
A draft language spec for records is available at:
http://cr.openjdk.java.net/~gbierman/8222777/8222777-20190823/specs/records-jls.html
<http://cr.openjdk.java.net/~gbierman/8222777/8222777-20190823/specs/records-jls.html>
This spec doesn’t yet discuss varargs records - to appear in the next draft.
All comments welcomed!
Thanks,
Gavin