On Thu, 12 Jan 2023 09:28:46 GMT, Per Minborg <pminb...@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 > > Per Minborg has updated the pull request incrementally with one additional > commit since the last revision: > > Add @Override annotations src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java line 995: > 993: Node<K,V>[] t; > 994: if ((t = table) != null) { > 995: Traverser<K,V> it = new Traverser<>(t, t.length, 0, > t.length); Using diamond is one way to modernize this code, using `var` would be another, even more concise way. Consider: Suggestion: var it = new Traverser<K, V>(t, t.length, 0, t.length); I don't support blindly using `var` everywhere, but I believe when the RHS of the assignment spells out the type that's exactly the kind of usage envisioned for it. ------------- PR: https://git.openjdk.org/jdk/pull/11924