[External] : Re: Draft Spec for Flexible Constructor Bodies (JEP 513)

Chen Liang chen.l.liang at oracle.com
Wed Apr 23 17:22:40 UTC 2025


Indeed, on second thought, this just does not extend record canonical constructors, but does not remove any ability. We can have a separate migration mechanism for record constructors in a later release.
________________________________
From: Archie Cobbs <archie.cobbs at gmail.com>
Sent: Wednesday, April 23, 2025 12:02 PM
To: Chen Liang <chen.l.liang at oracle.com>
Cc: forax at univ-mlv.fr <forax at univ-mlv.fr>; amber-spec-experts <amber-spec-experts at openjdk.java.net>; amber-spec-comments <amber-spec-comments at openjdk.org>
Subject: Re: [External] : Re: Draft Spec for Flexible Constructor Bodies (JEP 513)

On Tue, Apr 22, 2025 at 6:54 PM Chen Liang <chen.l.liang at oracle.com<mailto:chen.l.liang at oracle.com>> wrote:
However, one problem with FCB I see that can block its finalization is its lack of support for records - records must not have a superconstructor invocation, and as a result, records cannot have early construction field assignments, because without an explicit invocation, per JLS, the canonical constructor body will be late construction; and such a body can use "this", which makes it incompatible to simply reinterpret a canonical constructor body as in an early construction context.

I don't claim to be an impartial observer, but in my opinion this issue should not be a show-stopper for finalization of FCB.

My rationale:

1. Canonical record constructors already limit what you can do before super(): namely, anything that you can do within a super() call parameter list. So this is not a new problem.

2. This restriction does become more acute with strict fields, but that just means it may need to be addressed along with strict fields (i.e., later). There are simple answers, e.g., allowing a parameterless "super" keyword to demarcate the prologue/epilogue boundary, and which would syntactically mirror the parameterless constructor declaration.

-Archie

--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-observers/attachments/20250423/3e2ab84a/attachment-0001.htm>


More information about the amber-spec-observers mailing list