bworld - java laucher vs restricted field
Jan Lahoda
jan.lahoda at oracle.com
Wed Feb 4 19:32:19 UTC 2026
Hi Remi,
Thanks for the report. Please see for what I think is the cause and a
possible fix:
https://github.com/openjdk/valhalla/pull/2039
Jan
On 2/4/26 16:43, Remi Forax wrote:
> Hello,
> I'm testing the restricted fields on the bworld branch,
> running the source code directly with the command "java" without using javac failed.
>
> step to reproduce:
>
> $JAVA_HOME/bin/java --enable-preview ComplexBox.java
>
> ComplexBox.java:10: error: cannot access NullRestricted
> public class ComplexBox {
> ^
> class file for jdk.internal.vm.annotation.NullRestricted not found
> 1 error
> error: compilation failed
>
> If instead, I first compile and then run, there is no issue.
>
> ---
> public class ComplexBox {
> public value record Complex(int re, int im) {}
>
> private Complex! complex;
>
> public ComplexBox(Complex! complex) {
> this.complex = complex;
> super();
> }
>
> @Override
> public String toString() {
> return "ComplexBox (" + complex + ")";
> }
>
> // -XX:+UnlockDiagnosticVMOptions -XX:+PrintInlineLayout
> static void main() {
> var complex = new Complex(2, 1);
> var box = new ComplexBox(complex);
>
> IO.println(box);
> }
> }
More information about the valhalla-dev
mailing list