RFR: Add checks to reject creation of non-empty null-restricted arrays w/o initializer
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Jan 9 12:36:34 UTC 2026
This PR adds checks in `Attr` so that creation of non-empty null-restricted arrays w/o an initializer is not allowed.
The code is very careful in determining situations where null-restrictions on the array element type are irrelevant, such as:
* when the array size is a constant zero - `new String![0]` -- as in this case the restricted array is empty, so there's nothing to initialize
* when one or more dimensions are missing - `new String![10][]` -- as in this case the outer array (of size 10) is just filled with `null`s, as the inner array lacks a size
* when one or more intermediate dimensions is the constant zero - `new String[0][10]` -- as in this case nothing is really created, as the outer array is empty
A test has been added to (hopefully) cover all such pesky cases.
-------------
Commit messages:
- Fix regression tests
- Merge branch 'bworld' into restricted_array_new_attr
- Initial push
- Remove spurious changes
- Revert changes to stripMetadata & friends
- Initial push
Changes: https://git.openjdk.org/valhalla/pull/1876/files
Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1876&range=00
Stats: 56 lines in 6 files changed: 53 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/valhalla/pull/1876.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1876/head:pull/1876
PR: https://git.openjdk.org/valhalla/pull/1876
More information about the valhalla-dev
mailing list