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

Chen Liang liach at openjdk.org
Fri Jan 30 03:28:54 UTC 2026


On Fri, 30 Jan 2026 03:14:16 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> 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

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

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

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


More information about the valhalla-dev mailing list