On Mon, 18 May 2026 12:24:27 GMT, Per Minborg <[email protected]> wrote:

>> This PR proposes to replace older `Collection.unmodifiable` wrappers with 
>> `Set.of()` instead. This can improve performance, reduce footprint, and 
>> reduce maintenance. There is also occasional use of `Map.of()` in nearby 
>> places where `Set.of()` was introduced.
>> 
>> ---------
>> - [X] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Per Minborg has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Revert change

`sun.security.util.KnownOIDs.name2enum` can be changed to use [`Map::copyOf`] 
instead of [`ConcurrentHashMap`][][^1], since it’s not actually modified after 
`<clinit>`:

private static final Map<String, KnownOIDs> name2enum;

static {
        final Map<String, KnownOIDs> name2enumImpl = new HashMap<>();
        for (KnownOIDs o : KnownOIDs.values()) {
                register(name2enumImpl, o);
        }
        name2enum = Map.copyOf(name2enumImpl);
}

private static void register(final Map<String, KnownOIDs> name2enum, KnownOIDs 
o) {
        // existing method
}


[^1]: Which is also `null`‑hostile

[`Map::copyOf`]: 
https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/util/Map.html#copyOf(java.util.Map)
[`ConcurrentHashMap`]: 
https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/util/concurrent/ConcurrentHashMap.html

-------------

PR Comment: https://git.openjdk.org/jdk/pull/31135#issuecomment-4480549306

Reply via email to