Updated Draft specs for JEP 359 (Records)

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Nov 21 16:23:03 UTC 2019


Hi Gavin, looks great - some minor comments:

* I'm having problem parsing this sentence

"An explicitly declared accessor method is not annotated with any 
applicable annotation that appears on the corresponding record component."

What do you mean exactly? I guess you mean that the explicit accessor 
does not implicitly get from the components (e.g. you have to restate them)?

* when you speak of explicit canonical constructor, I see this:

"The body of the canonical constructor must not contain a return 
statement (14.17)."

Why do we have this restriction? After all, as with any other 
constructor, the language/compiler will ensure that, at the point of 
'return' all final fields have been assigned, no?

* "If a record type R declares constructors other than the canonical 
constructor"

I think it would be better to rephrase in term of "constructor that is 
not override-equivalent with canonical constructor" - the term 'other' 
is vague. Also, override equivalence takes into consideration cases like 
these:

record Foo(List<String> ls) {
     Foo(List ls) { } //am I canonical?
}

Typically we allow such moves - for instance there could be clients of 
the record class which might need a looser signature for compatibility 
reason. Same should hold for accessors - e.g.

interface RawGetter {
    List list();
}

class ListHolder(List<String> list) implements RawGetter { } //is this 
legal?


In other words:

* having a more-specific accessor/constructor parameter type (e.g. 
List<String>) where the component is raw (e.g. List) should always be ok
* having a less-specific accessor/constructor parameter type (e.g. List) 
where the component is generic (e.g. List<String>) could be allowed with 
unchecked warnings (as we do for override)


Maurizio





On 21/11/2019 15:01, Gavin Bierman 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 
>
>
> 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.bierman at oracle.com 
>> <mailto:gavin.bierman at 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
>>
>> (Alongside is a draft JVM spec for this feature:
>>
>> 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.bierman at oracle.com 
>>> <mailto:gavin.bierman at 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
>>>
>>> This spec doesn’t yet discuss varargs records - to appear in the 
>>> next draft.
>>>
>>> All comments welcomed!
>>>
>>> Thanks,
>>> Gavin
>>
>


More information about the amber-dev mailing list