Draft JLS spec for records
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Sep 3 13:40:06 UTC 2019
Nits
* in 8.10.1:
"Each record component in the /RecordHeader/ declares one |private
final| field in the record class whose name is same as the /Identifier/
in the record component."
This seems a bit early. Also, you repeat the same in 8.10.3, which is
arguably a much better place?
* Also, in 8.10.1:
"It is a compile-time error for a record header to declare a record
component with the name clone, finalize, getClass, hashCode, notify,
notifyAll, readObjectNoData, readResolve, serialPersistentFields,
toString, wait, or writeReplace."
Would this make more sense in 8.10.3?
* 8.10.4:
"A record declaration may contain constructor declarations. These
constructor declarations may be of the same form as a constructor
declaration in a class type. In addition, a record declaration may
contain a /compact constructor declaration/, which is a form of
constructor declaration that explicitly declares the canonical constructor."
I think this sounds a bit flat - that is, from this paragraph is not
really clear what a compact constructor declaration is for - I guess you
can also re-declare the canonical constructor using normal old-style
constructor syntax, no?
I would omit the ", which is a form of constructor declaration that
explicitly declares the canonical constructor" and simply skip over to
the next para.
* 8.10.4:
" one which is identical to the record header of /R/ is added
implicitly." - not sure I would lean on 'identical' here. Maybe better
to say that the formal parameter list is _derived_ from the record
header (e.g. parameter names/types are the same, and in same order, as
record components)?
* initialised - UK vs US english - not sure which we should use, but I
see other uses of 'initialized' around
* 9.7.4:
we say this:
"
It is a compile-time error if an annotation of type /T/ is syntactically
a modifier for:
[...]
a record component but T is not applicable to record component
declarations, type contexts, type parameter declarations, field
declarations, or method declarations."
But it's not super clear what happens to the annotations that are
actually correct and how they are propagated. Should e.g. the fact that
a field decl anno on a record element is propagated on its synthetic
private field be covered by the JLS?
Maurizio
On 23/08/2019 22:25, Gavin Bierman 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20190903/b0ef1a54/attachment.html>
More information about the amber-spec-experts
mailing list