JDK-8236623 : Records: Clarify interaction between records and varargs
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 14
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-01-02
  • 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.

To download the current JDK release, click here.
JDK 15
15Fixed
Related Reports
Relates :  
Description
Both of the following are accepted by the current `javac`, but probably should not be:

```
record Test(int[] args) {
  public Test(int... args) {
    this.args = args;
  }
}
```
and

```
record Test(int... args) {
  public Test(int[] args) {
    this.args = args;
  }
}
```

These both probably fall into the "an explicit canonical ctor should match the record descriptor exactly" bucket.  There is little benefit to such divergence.
Comments
Records spec now has the following requirement of canonical constructors: > 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. The second sentence rules out the examples.
10-04-2020