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

Chen Liang liach at openjdk.org
Tue Oct 28 18:02:03 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".

This pull request has now been integrated.

Changeset: 20e55faf
Author:    Chen Liang <liach at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/20e55fafb39dd74a044d7fda8a2b3409cc00bf54
Stats:     2 lines in 1 file changed: 0 ins; 0 del; 2 mod

8370687: Improve before constructor has been called error message

Reviewed-by: vromero

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

PR: https://git.openjdk.org/jdk/pull/28007


More information about the compiler-dev mailing list