JDK-8225052 : javax.lang.model support for records
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-05-30
  • Updated: 2023-08-28
  • Resolved: 2019-12-04
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 14
14 b27Fixed
Related Reports
Blocks :  
CSR :  
Relates :  
Description
Add javax.lang.model support for records.
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/8e76f81d057a User: vromero Date: 2019-12-04 21:06:04 +0000
04-12-2019

Suggestion: it might be nice to put MANDATED on the necessary parameters when the "default" constructor is defined implicitly, as in record R(int r) { R { System.out.println("create an R"); } }
07-08-2019

Re: previous comment: it looks like the MANDATED flag may be set when needed, in TypeEnter $ grep RECORD.*MANDATED src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java MethodDef(make.Modifiers(Flags.PUBLIC | Flags.RECORD | Flags.MANDATED), MethodDef(make.Modifiers(Flags.PUBLIC | Flags.RECORD | Flags.FINAL | Flags.MANDATED), MethodDef(make.Modifiers(Flags.PUBLIC | Flags.RECORD | Flags.FINAL | Flags.MANDATED), MethodDef(make.Modifiers(Flags.PRIVATE | Flags.RECORD | Flags.FINAL | Flags.MANDATED),
07-08-2019

The current implementation conflates a member being required to be provided with Origin.MANDATED, since it ignores the possibility that the member may have been explicitly defined. This applies to all executable members. Here's the relevant code in JavacElements.getOrigin. if ((sym.flags() & (Flags.RECORD | Flags.MANDATED)) != 0) return Origin.MANDATED; Since we already have a MANDATED flag, we should ensure the flag is set on members of a record that were declared implicitly, and remove Flags.RECORD from that expression.
07-08-2019