RFR: 8304146: Refactor VisibleMemberTable (LocalMemberTable) [v2]
Jonathan Gibbons
jjg at openjdk.org
Wed Mar 15 20:21:24 UTC 2023
On Wed, 15 Mar 2023 20:01:31 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
>> True, my previous suggestion is largely trivial.
>>
>> In addition, I suggest to run `replaceAll` to ensure the map elements of each value of `namedMembers` is unmodifiable as well:
>>
>> namedMembers.replaceAll((k, m) -> {
>> m.replaceAll((n, members) -> Collections.unmodifiableList(members));
>> return Collections.unmodifiableMap(m);
>> });
>
> I believe that shallow unmodifiability of namedMembers is a bug, which you spotted. We should either fix it by making it deeply unmodifiable, or remove this defensiveness altogether: those lists and maps (especially maps) are internal and should never escape. I suppose, it's better to fix it now and revisit later.
Or just comment the existing code, indicating that this is just a shallow copy.
-------------
PR: https://git.openjdk.org/jdk/pull/13044
More information about the javadoc-dev
mailing list