RFR: 8370687: Improve before constructor has been called error message

Vicente Romero vromero at openjdk.org
Mon Oct 27 19:46:05 UTC 2025


On Mon, 27 Oct 2025 19:27:43 GMT, Chen Liang <liach at openjdk.org> wrote:

> In the Valhalla EA2 preview, Value class and record constructor body is in prologue by default, as opposed to all existing constructors and all identity constructors in EA2. This causes a confusion because the error message `cant.ref.before.ctor.called` can appear in such constructors without explicit constructor invocations.
> 
> After discussion with @vicente-romero-oracle, we decide to commit this change onto mainline: these two errors never happen in constructors without explicit constructor invocation (colloquially "this" or "super" calls) on mainline, so this message update would not create new confusions. This is future-proof, and is more consistent with the related `call.must.only.appear.in.ctor` message, which is "explicit constructor invocation may only appear within a constructor body".

lgtm

-------------

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/28007#pullrequestreview-3385191408


More information about the compiler-dev mailing list