RFR: Add alternate desugaring strategy for null-restricted arrays [v3]
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Jan 9 16:39:35 UTC 2026
> Creation of null-restricted arrays are desugared as calls into methods of the `ArrayCreation` class, as we need to set the "strict" marker on the created array.
> Currently the JVM doesn't support creation of null-restricted array for non-value types, so in this PR I cleaned up the `ArrayCreation` API to reflect more what javac needs. Also, according to our long term plans, `ArrayCreation` is really implemented on top of a new primitive in `Array`, which will be refined later to support creation of arrays with desired flags.
>
> The translation strategy in javac is simple -- given an array initializer `{ .. }`, we just assign the initializer to a temp variable, then wrap the initializer using a call to `ArrayCreation::copied` to obtain the new array. Then we wrap everything in a let expression, so that things compose nicely.
>
> While writing the test I realized that our combo framework failed to report compilation and execution failures. As I fixed that issue, I realized that a test I've added (`NullRestrictionReflectiveTest`) was not working correctly, as it had compilaton issues with some of the combinations and even a latent issue in signature parsing which I have now fixed.
Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
Address review comments
-------------
Changes:
- all: https://git.openjdk.org/valhalla/pull/1877/files
- new: https://git.openjdk.org/valhalla/pull/1877/files/0bf345a0..91b152e3
Webrevs:
- full: https://webrevs.openjdk.org/?repo=valhalla&pr=1877&range=02
- incr: https://webrevs.openjdk.org/?repo=valhalla&pr=1877&range=01-02
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/valhalla/pull/1877.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1877/head:pull/1877
PR: https://git.openjdk.org/valhalla/pull/1877
More information about the valhalla-dev
mailing list