RFR: 8356080: Address post-integration comments for Stable Values [v3]
Per Minborg
pminborg at openjdk.org
Tue May 13 06:25:03 UTC 2025
On Mon, 12 May 2025 21:12:36 GMT, Luca Kellermann <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/ImmutableCollections.java line 518:
>>
>>> 516:
>>> 517: private boolean allowNulls() {
>>> 518: return root instanceof ListN<?> listN && listN.allowNulls;
>>
>> I think this should stay here (or some other change is needed). `StableSubList` doesn't override `indexOf` and `lastIndexOf`, so they will throw when given `null`, even though the list could contain `null`.
>
> Example code that I think will fail with the changes in this PR:
>
> var list = StableValue.list(42, x -> x == 23 ? null : x);
> IO.println(list.indexOf(null)); // 23
> IO.println(list.subList(10, 30).indexOf(null)); // NPE, should be 13
Good catch. I will add a test that will test all list view combinations.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25004#discussion_r2086007633
More information about the core-libs-dev
mailing list