[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:06 UTC 2025


On Tue, 25 Mar 2025 20:40:15 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: ea8521de
Author:    Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/valhalla/commit/ea8521de3f1627ec35894be33bed14988572fae1
Stats:     71 lines in 6 files changed: 51 ins; 14 del; 6 mod

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

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

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


More information about the valhalla-dev mailing list