[records] Compact constructor type parameters

Tagir Valeev amaembo at gmail.com
Sat Nov 9 11:07:29 UTC 2019


Hello!

Reading the latest JLS spec draft for records, chapter 8.10.5 [1] I
see the following:

A compact constructor declaration provides an alternative, succinct
means to declare a canonical constructor for a record type.
CompactConstructorDeclaration:{ Annotation } { ConstructorModifier } [
TypeParameters ] SimpleTypeName ConstructorBody

Is it really useful to allow type parameters specification for a
compact constructor, given that we cannot alter the formal parameters
list, thus we cannot use them there? Yes, we could use them to declare
local variables but this is an implementation detail, thus it should
not leak to the clients (especially given the fact that canonical
constructors are always public). Should not we exclude type parameters
from the compact constructor declaration?

I think we can go even further and disable type parameters for
explicit canonical constructor declaration (not in compact form) as
well. WDYT?

With best regards,
Tagir Valeev.

[1] http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191031/specs/records-jls.html#jls-8.10.5


More information about the amber-spec-experts mailing list