Integrated: 8339357: [lw5] make non-nullable instance fields strict

Vicente Romero vromero at openjdk.org
Wed Sep 11 02:24:57 UTC 2024


syncing javac with [[1](https://bugs.openjdk.org/browse/JDK-8303099)], in particular section: `Field and array initialization`:

- A null-restricted instance field without an initializer must be definitely assigned before the (explicit or implicit) super(...) call in each of the class's constructors. The [Flexible Constructor Bodies JEP](https://openjdk.org/jeps/8325803) allows the necessary initialization code to be written at the start of a constructor. In this early construction context, the initialization logic is not allowed to refer to this or risk any attempts to read the uninitialized field.
- If a null-restricted instance field has an initializer, the initializer is executed at the start of each constructor, before the super(...) call. (Constructors that call this(...) are a special case and, as usual, do not execute initializers at all.) Again, this means that the initialization logic of the field occurs in an early construction context and may not refer to this or risk any reads of the uninitialized field.

TIA

[1] https://bugs.openjdk.org/browse/JDK-8303099

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

Commit messages:
 - adding tests
 - 8339357: [lw5] make non-nullable fields strict

Changes: https://git.openjdk.org/valhalla/pull/1234/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1234&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8339357
  Stats: 103 lines in 4 files changed: 91 ins; 0 del; 12 mod
  Patch: https://git.openjdk.org/valhalla/pull/1234.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1234/head:pull/1234

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


More information about the valhalla-dev mailing list