On Fri, 30 Jan 2026 02:56:47 GMT, Vicente Romero <[email protected]> wrote:
>> javac is automatically placing the initializers of null restricted fields
>> before the super invocation. This is incorrect, null restricted fields are
>> not strict and those initializers should be placed after the super. But
>> javac will check that null restricted fields have been initialized before a
>> super invocation. This implies that null restricted fields should not have
>> initializers and users should manually initialize them in all the
>> constructors and before explicit super invocations.
>
> Vicente Romero has updated the pull request incrementally with one additional
> commit since the last revision:
>
> addressing review comments
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java line
1935:
> 1933: }
> 1934: if (sym.kind == VAR) {
> 1935: if ((flags & STRICT) != 0 || (flags & MARK_STRICT_INIT) !=
> 0 || types.isNonNullable(sym.type)) {
non-nullable fields should have the strict flag in the class file but are
different to other, strictly, strict fields. The main difference is that the
compiler doesn't automatically place the initializers before the super
invocation. This is why I decided to set the strict flag at the end when we are
about to write the field into the class file. Setting it in Check would imply,
for example, more complex tracking in Flow
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/1990#discussion_r2744436248