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

Archie Cobbs archie.cobbs at gmail.com
Wed Apr 23 17:02:42 UTC 2025


On Tue, Apr 22, 2025 at 6:54 PM Chen Liang <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/8318b428/attachment.htm>


More information about the amber-spec-observers mailing list