RFR: Tweak error when a null-restricted field is missing an initializer

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Jan 13 16:38:28 UTC 2026


The logic for issuing an error when a strict (instance) field is missing an initializer relies on there being some constructor at the end of which the error is reported.

But if the constructor is a default constructor, there's no valid position where to report the error.

To fix this, I looked at how errors for uninitialized final fields. In case of a default constructor the error is reported against the field decl, not the constructor. I've done the same for non-nullable fields.

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

Commit messages:
 - Initial push

Changes: https://git.openjdk.org/valhalla/pull/1897/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1897&range=00
  Stats: 47 lines in 5 files changed: 34 ins; 6 del; 7 mod
  Patch: https://git.openjdk.org/valhalla/pull/1897.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1897/head:pull/1897

PR: https://git.openjdk.org/valhalla/pull/1897


More information about the valhalla-dev mailing list