RFR: 8299852: Modernize ConcurrentHashMap

Martin Buchholz martin at openjdk.org
Tue Jan 10 23:03:15 UTC 2023


On Tue, 10 Jan 2023 10:32:34 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> `java.util.concurrent.ConcurrentHashMap` is relatively old and has not been updated to reflect the current state of Java and can be modernized: 
> 
> * Add `@Serial` annotations 
> * Seal classes and restrict subclassing for internal classes 
> * Use pattern matching for instance 
> * Remove redundant modifiers (such as some final declarations) 
> * Use Objects.requireNonNull for invariant checking 
> * Use diamond operators instead of explicit types 
> * Simplify expressions using Math::max

src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java line 629:

> 627:      * exported).  Otherwise, keys and vals are never null.
> 628:      */
> 629:     static sealed class Node<K,V> implements Map.Entry<K,V> {

There is a long term modernization task of making nested classes private to make use of
https://openjdk.org/jeps/181
It looks like this is an example.

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

PR: https://git.openjdk.org/jdk/pull/11924


More information about the core-libs-dev mailing list