[lworld] Integrated: 8352892: [lworld] javac is issuing a compiler error for a method that just sets a strict field

Vicente Romero vromero at openjdk.org
Wed Mar 26 20:06:05 UTC 2025


when compiling this code:

import jdk.internal.vm.annotation.*;

value class Point {
    Point(int i, int j) {}
}

class Parent {
    @Strict
    @NullRestricted
    Point fp = new Point(1, 2); /* Flattenable and flattened inline field */

    public void setFp(Point p) { fp = p; }
}

javac is failing with:

myTests/StrictFieldsError.java:12: error: cannot assign to fp after supertype constructor has been called
    public void setFp(Point p) { fp = p; }
                                 ^
Note: myTests/StrictFieldsError.java uses preview features of Java SE 25.
Note: Recompile with -Xlint:preview for details.
1 error

command:

build/langtools/bin/javac -d out --enable-preview -source 25 --add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED myTests/StrictFieldsError.java


this code should be accepted by the compiler

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

Commit messages:
 - refactoring
 - additional infra for value records
 - 8352892: [lworld] javac is issuing a compiler error for a method that just sets a strict field

Changes: https://git.openjdk.org/valhalla/pull/1408/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1408&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8352892
  Stats: 71 lines in 6 files changed: 51 ins; 14 del; 6 mod
  Patch: https://git.openjdk.org/valhalla/pull/1408.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1408/head:pull/1408

PR: https://git.openjdk.org/valhalla/pull/1408


More information about the valhalla-dev mailing list