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

Chen Liang liach at openjdk.org
Mon Oct 27 19:34:40 UTC 2025


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".

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

Commit messages:
 - 8370687: Improve before constructor has been called error message

Changes: https://git.openjdk.org/jdk/pull/28007/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28007&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8370687
  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/28007.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28007/head:pull/28007

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


More information about the compiler-dev mailing list