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
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
- links to
-
Commit(lworld) openjdk/valhalla/ea8521de
-
Review(lworld) openjdk/valhalla/1408