bworld - java laucher vs restricted field
Remi Forax
forax at univ-mlv.fr
Wed Feb 4 15:43:00 UTC 2026
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