Integrated: 8339357: [lw5] make non-nullable instance fields strict
Vicente Romero
vromero at openjdk.org
Wed Sep 11 02:24:57 UTC 2024
On Tue, 3 Sep 2024 17:27:22 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> 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
This pull request has now been integrated.
Changeset: 9daec2e6
Author: Vicente Romero <vromero at openjdk.org>
URL: https://git.openjdk.org/valhalla/commit/9daec2e662cca0d8fcb583481726e0a762aff5ff
Stats: 103 lines in 4 files changed: 91 ins; 0 del; 12 mod
8339357: [lw5] make non-nullable instance fields strict
-------------
PR: https://git.openjdk.org/valhalla/pull/1234
More information about the valhalla-dev
mailing list