[records] Latest spec available
gavin.bierman at oracle.com
Tue Apr 28 05:48:30 UTC 2020
The latest draft of the spec for the second preview of records is available at:
The changes from the first preview spec  have been discussed on this list and
are listed below for reference. However, with an eye to a better treatment of
nesting in Java as discussed by Brian  we have taken the opportunity to
refactor the spec somewhat to allow for a better treatment of local declarations
including local records.
We have kept these refactorings as two separate JLS change documents, linked to
from the records spec. The first document clarifies the usage of terms related
to classes and interfaces, and more clearly distinguishes them from types. The
second builds on this and regularizes the treatment of nested and local
declarations. In particular, it relaxes previous restrictions and permits *local
interface and enum declarations*. The records spec then builds on top of these
two changes to the JLS to support records (and local record declarations).
PS: The URLs will change once we have a JEP number for the second preview of
The changes are the same as those in the first preview of Records in Java SE 14,
except for the following:
- All text now uses the terminology of "Consistent Class and Interface
Terminology" spec change document
- The handling of local records now builds on the changes in "Local Static
Interfaces and Enum Classes" spec change document
- Removed unnecessary change to 4.12.4
- 8.10.1: Removed possibility of `final` modifier for record components
- 8.10.1: Clarified that annotations on a record component only remain on the
component if its annotation type is applicable in the record component context
- 8.10.1: Corrected text around use of `@SafeVarArgs` annotation
- 8.10.4: Removed requirement that canonical constructor must be `public`. Any
access modifier must provide at least as much access as the record class. If a
canonical constructor is implicitly declared, then its access modifier is the
same as the record class.
- 8.10.4: Added requirement 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 must be a variable arity parameter if and only
if the corresponding record component is a variable arity record component.
- 8.10.4 Added error condition if a field corresponding to a record component of
a record class is neither DA nor DU in the body of a compact constructor.
- 220.127.116.11 New case for using `@Override` annotation to declare that a method is
an accessor method for a record component.
More information about the amber-spec-experts