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
>> 
> 

Reply via email to