RFR: Fixing null restricted types for fields/methods in compact source files.

Jan Lahoda jlahoda at openjdk.org
Thu Jan 15 21:26:13 UTC 2026


The null restricted types don't seem to be supported for top-level fields/methods in compact source files:

$ cat /tmp/Compact.java 
String! s = "";
void main() {
}
$ ./build/linux-x86_64-server-release/jdk/bin/javac --enable-preview --source 27 /tmp/Compact.java 
/tmp/Compact.java:1: error: null restriction not supported in this type context
String! s = "";
      ^
1 error


This is a simple patch to fix that (removing the `unannotatedType(boolean)` method, as that is no longer used, to my knowledge. But it can be preserved, if preferred.

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

Commit messages:
 - Fixing null restricted types for fields/methods in compact source files.

Changes: https://git.openjdk.org/valhalla/pull/1916/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1916&range=00
  Stats: 23 lines in 2 files changed: 18 ins; 4 del; 1 mod
  Patch: https://git.openjdk.org/valhalla/pull/1916.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1916/head:pull/1916

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


More information about the valhalla-dev mailing list