JDK-8236599 : Records: Names of formal parameters in canonical constructors must match the corresponding record component
Type:Bug
Component:specification
Sub-Component:language
Affected Version:14
Priority:P3
Status:Resolved
Resolution:Fixed
Submitted:2019-12-31
Updated:2020-04-10
Resolved:2020-04-10
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
The spec should explicitly states that the names of formal parameters in the canonical constructor should be identical to the one of the corresponding record component
Comments
Spec has been updated
10-04-2020
The spec now includes the following text listing requirements of a canonical constructor:
> Each formal parameter in the formal parameter list of the constructor must have the same name and type as the corresponding record component. The formal parameter may be a variable arity parameter if and only if the corresponding record component is a variable arity record component.
10-04-2020
Rationale: The construction protocol is derived from the record description. Eventually, names may be part of the construction protocol (e.g., new Point(x: 1, y: 2)), and having records gratuitiously diverge from this serves no one. Further, in most cases, the user will prefer a compact constructor than a fully explicit one. There's no need for this degree of freedom, and at least one nontrivial downside.