RFR: javac should not place initializers of null restricted fields before the super invocation [v4]

Vicente Romero vromero at openjdk.org
Fri Jan 30 17:57:11 UTC 2026


On Fri, 30 Jan 2026 03:25:56 GMT, Chen Liang <liach at openjdk.org> wrote:

>> 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
>
> Just curious, if we have `!` fields assigned in early construction by different branches in if-else, do they generate early-larval/restricted frames properly, or are we using proxy locals right now

right now only proxy locals

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1990#discussion_r2747360129


More information about the valhalla-dev mailing list