RFR: 8328821: Map.of().entrySet() mutators should throw UnsupportedOperationException [v3]
Chen Liang
liach at openjdk.org
Tue Jul 9 19:26:19 UTC 2024
On Tue, 9 Jul 2024 19:19:41 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:
>> There is `testImmutableCollection`/`testImmutableSet` that takes an arbitrary nonexistent item for insertion/removal: https://github.com/openjdk/jdk/blob/598af2e51464be089b64da4024e62865c2c6ec72/test/jdk/java/util/Collection/MOAT.java#L665
>> I think a refactor of a generic `testCollMutatorsAlwaysThrow(Collection<T> c, T t)` and delegating the original Integer version to call `testCollMutatorsAlwaysThrow(c, ABSENT_VALUE)` would not be invasive.
>
> Thanks! Done.
>
> That pointed out that the mutators on `keySet()` and `values()` were not throwing UOE, so I have tentatively updated the PR to also fix that.
Thank you for this more comprehensive update! Definitely an improvement to bring the UOE behavior to all 3 of these view collections.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18522#discussion_r1671043314
More information about the core-libs-dev
mailing list