[lworld] RFR: 8373261: [lworld] VerifyError: Strict fields not a subset of initial strict instance fields

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Dec 17 13:59:26 UTC 2025


On Tue, 16 Dec 2025 20:06:08 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> The verifier is failing due to an incorrect EarlyLarvalFrame generated by javac. The issue can be reproduced by compiling this test case:
> 
> 
> public class Test {
>     static value class Val1 {
>         int i1;
>         int i2;
>         int i3;
>         int i4;
> 
>         public Val1() {
>             this.i1 = 0;
>             this.i2 = 0;
>             this.i3 = 0;
>             this.i4 = 0;
>         }
>     }
> 
>     static value class Val2 {
>         int i1;
>         Val1 val1;
> 
>         public Val2(boolean b) {
>             this.i1 = 0;
>             this.val1 = b ? null : new Val1(); // this statement will trigger the generation of an EarlyLarvalFrame
>         }
>     }
> 
>     public static void main(String[] args) {
>         Val2 val = new Val2(true);
>     }
> }
> 
> so from the example above, for `Val2`'s constructor, javac is generating an `EarlyLarvalFrame` that included `Val1`'s `i4` field as an uninitialized strict field. The reason is that method `findUninitStrictFields` in `Flow` was not stopping at the max valid local variable for the current method. There are some data structures that are reused during flow analysis without being cleared from method to method to save time. So basically this method was reading "logically erased" info left during the analysis of the previous constructor.
> 
> TIA for the review

Marked as reviewed by mcimadamore (Committer).

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 2122:

> 2120:             for (int i = firstadr; i < nextadr; i++) {
> 2121:                 JCVariableDecl variableDecl = vardecls[i];
> 2122:                 if (uninits.isMember(variableDecl.sym.adr) && variableDecl.sym.isStrict()) {

This could also be replaced with `uninints.isMember(i)` right?

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

PR Review: https://git.openjdk.org/valhalla/pull/1809#pullrequestreview-3587882053
PR Review Comment: https://git.openjdk.org/valhalla/pull/1809#discussion_r2627175201


More information about the valhalla-dev mailing list