RFR: 8328821: Map.of().entrySet() mutators should throw UnsupportedOperationException [v3]
Liam Miller-Cushon
cushon at openjdk.org
Tue Jul 9 19:23:54 UTC 2024
On Tue, 9 Jul 2024 17:43:32 GMT, Chen Liang <liach at openjdk.org> wrote:
>> `testCollMutatorsAlwaysThrow` expects a `Collection<Integer>` (not e.g. a `Collection<Entry<Integer, Integer>>`). MOAT could be refactored to handle that case. Do you think that's worth it, or have thoughts about what the cleanest way to do that would be?
>
> 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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18522#discussion_r1671039819
More information about the core-libs-dev
mailing list