diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java index c17acb0a2c0..0a18795a78b 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -627,7 +627,7 @@ public class ConcurrentHashMap extends AbstractMap * are special, and contain null keys and values (but are never * exported). Otherwise, keys and vals are never null. */ - static class Node implements Map.Entry { + static class Node implements Map.Entry { final int hash; final K key; volatile V val; @@ -765,7 +765,7 @@ static final Node tabAt(Node[] tab, int i) { return (Node)U.getReferenceAcquire(tab, ((long)i << ASHIFT) + ABASE); } - static final boolean casTabAt(Node[] tab, int i, + static final boolean casTabAt(Node[] tab, int i, Node c, Node v) { return U.compareAndSetReference(tab, ((long)i << ASHIFT) + ABASE, c, v); } @@ -1397,7 +1397,7 @@ public boolean equals(@Nullable Object o) { * Stripped-down version of helper class used in previous version, * declared for the sake of serialization compatibility. */ - static class Segment extends ReentrantLock implements Serializable { + static class Segment extends ReentrantLock implements Serializable { private static final long serialVersionUID = 2249069246763182397L; final float loadFactor; Segment(float lf) { this.loadFactor = lf; } @@ -2210,7 +2210,7 @@ public long mappingCount() { * @return the new set * @since 1.8 */ - public static KeySetView newKeySet() { + public static KeySetView newKeySet() { return new KeySetView (new ConcurrentHashMap(), Boolean.TRUE); } @@ -2227,7 +2227,7 @@ public long mappingCount() { * elements is negative * @since 1.8 */ - public static KeySetView newKeySet(int initialCapacity) { + public static KeySetView newKeySet(int initialCapacity) { return new KeySetView (new ConcurrentHashMap(initialCapacity), Boolean.TRUE); } @@ -2254,7 +2254,7 @@ public KeySetView keySet(V mappedValue) { /** * A node inserted at head of bins during transfer operations. */ - static final class ForwardingNode extends Node { + static final class ForwardingNode extends Node { final Node[] nextTable; ForwardingNode(Node[] tab) { super(MOVED, null, null); @@ -2291,7 +2291,7 @@ Node find(int h, Object k) { /** * A place-holder node used in computeIfAbsent and compute. */ - static final class ReservationNode extends Node { + static final class ReservationNode extends Node { ReservationNode() { super(RESERVED, null, null); } @@ -2717,7 +2717,7 @@ else if ((b = tabAt(tab, index)) != null && b.hash >= 0) { /** * Returns a list of non-TreeNodes replacing those in given list. */ - static Node untreeify(Node b) { + static Node untreeify(Node b) { Node hd = null, tl = null; for (Node q = b; q != null; q = q.next) { Node p = new Node(q.hash, q.key, q.val); @@ -2735,7 +2735,7 @@ else if ((b = tabAt(tab, index)) != null && b.hash >= 0) { /** * Nodes for use in TreeBins. */ - static final class TreeNode extends Node { + static final class TreeNode extends Node { TreeNode parent; // red-black tree links TreeNode left; TreeNode right; @@ -2795,7 +2795,7 @@ else if ((q = pr.findTreeNode(h, k, kc)) != null) * forcing writers (who hold bin lock) to wait for readers (who do * not) to complete before tree restructuring operations. */ - static final class TreeBin extends Node { + static final class TreeBin extends Node { TreeNode root; volatile TreeNode first; volatile Thread waiter; @@ -3110,7 +3110,7 @@ else if (p == pp.right) /* ------------------------------------------------------------ */ // Red-black tree methods, all adapted from CLR - static TreeNode rotateLeft(TreeNode root, + static TreeNode rotateLeft(TreeNode root, TreeNode p) { TreeNode r, pp, rl; if (p != null && (r = p.right) != null) { @@ -3128,7 +3128,7 @@ else if (pp.left == p) return root; } - static TreeNode rotateRight(TreeNode root, + static TreeNode rotateRight(TreeNode root, TreeNode p) { TreeNode l, pp, lr; if (p != null && (l = p.left) != null) { @@ -3146,7 +3146,7 @@ else if (pp.right == p) return root; } - static TreeNode balanceInsertion(TreeNode root, + static TreeNode balanceInsertion(TreeNode root, TreeNode x) { x.red = true; for (TreeNode xp, xpp, xppl, xppr;;) { @@ -3201,7 +3201,7 @@ else if (!xp.red || (xpp = xp.parent) == null) } } - static TreeNode balanceDeletion(TreeNode root, + static TreeNode balanceDeletion(TreeNode root, TreeNode x) { for (TreeNode xp, xpl, xpr;;) { if (x == null || x == root) @@ -3296,7 +3296,7 @@ else if ((xpl = xp.left) == x) { /** * Checks invariants recursively for the tree of Nodes rooted at t. */ - static boolean checkInvariants(TreeNode t) { + static boolean checkInvariants(TreeNode t) { TreeNode tp = t.parent, tl = t.left, tr = t.right, tb = t.prev, tn = (TreeNode)t.next; if (tb != null && tb.next != t) @@ -3331,7 +3331,7 @@ else if ((xpl = xp.left) == x) { * traverser that must process a region of a forwarded table before * proceeding with current table. */ - static final class TableStack { + static final class TableStack { int length; int index; Node[] tab; @@ -3359,7 +3359,7 @@ static final class TableStack { + static class Traverser { Node[] tab; // current table; updated if resized Node next; // the next entry to use TableStack stack, spare; // to save/restore on ForwardingNodes @@ -3451,7 +3451,7 @@ private void recoverState(int n) { * Base of key, value, and entry Iterators. Adds fields to * Traverser to support iterator.remove. */ - static class BaseIterator extends Traverser { + static class BaseIterator extends Traverser { final ConcurrentHashMap map; Node lastReturned; BaseIterator(Node[] tab, int size, int index, int limit, @@ -3473,7 +3473,7 @@ public final void remove() { } } - static final class KeyIterator extends BaseIterator + static final class KeyIterator extends BaseIterator implements Iterator, Enumeration { KeyIterator(Node[] tab, int size, int index, int limit, ConcurrentHashMap map) { @@ -3493,7 +3493,7 @@ public final K next() { public final K nextElement() { return next(); } } - static final class ValueIterator extends BaseIterator + static final class ValueIterator extends BaseIterator implements Iterator, Enumeration { ValueIterator(Node[] tab, int size, int index, int limit, ConcurrentHashMap map) { @@ -3513,7 +3513,7 @@ public final V next() { public final V nextElement() { return next(); } } - static final class EntryIterator extends BaseIterator + static final class EntryIterator extends BaseIterator implements Iterator> { EntryIterator(Node[] tab, int size, int index, int limit, ConcurrentHashMap map) { @@ -3535,7 +3535,7 @@ public final Map.Entry next() { /** * Exported Entry for EntryIterator. */ - static final class MapEntry implements Map.Entry { + static final class MapEntry implements Map.Entry { final K key; // non-null V val; // non-null final ConcurrentHashMap map; @@ -3577,7 +3577,7 @@ public V setValue(V value) { } } - static final class KeySpliterator extends Traverser + static final class KeySpliterator extends Traverser implements Spliterator { long est; // size estimate KeySpliterator(Node[] tab, int size, int index, int limit, @@ -3616,7 +3616,7 @@ public int characteristics() { } } - static final class ValueSpliterator extends Traverser + static final class ValueSpliterator extends Traverser implements Spliterator { long est; // size estimate ValueSpliterator(Node[] tab, int size, int index, int limit, @@ -3654,7 +3654,7 @@ public int characteristics() { } } - static final class EntrySpliterator extends Traverser + static final class EntrySpliterator extends Traverser implements Spliterator> { final ConcurrentHashMap map; // To export MapEntry long est; // size estimate @@ -4442,7 +4442,7 @@ public int reduceEntriesToInt(long parallelismThreshold, /** * Base class for views. */ - abstract static sealed class CollectionView + abstract static sealed class CollectionView implements Collection, java.io.Serializable permits EntrySetView, KeySetView, ValuesView { private static final long serialVersionUID = 7249069246763182397L; final ConcurrentHashMap map; @@ -4623,7 +4623,7 @@ public final boolean retainAll(Collection c) { * * @since 1.8 */ - public static final class KeySetView extends CollectionView + public static final class KeySetView extends CollectionView implements Set, java.io.Serializable { private static final long serialVersionUID = 7249069246763182397L; @SuppressWarnings("serial") // Conditionally serializable @@ -4749,7 +4749,7 @@ public void forEach(Consumer action) { * values, in which additions are disabled. This class cannot be * directly instantiated. See {@link #values()}. */ - static final class ValuesView extends CollectionView + static final class ValuesView extends CollectionView implements Collection, java.io.Serializable { private static final long serialVersionUID = 2249069246763182397L; ValuesView(ConcurrentHashMap map) { super(map); } @@ -4825,7 +4825,7 @@ public void forEach(Consumer action) { * entries. This class cannot be directly instantiated. See * {@link #entrySet()}. */ - static final class EntrySetView extends CollectionView> + static final class EntrySetView extends CollectionView> implements Set>, java.io.Serializable { private static final long serialVersionUID = 2249069246763182397L; EntrySetView(ConcurrentHashMap map) { super(map); } @@ -4922,7 +4922,7 @@ public void forEach(Consumer> action) { * class Traverser, because we need to subclass CountedCompleter. */ @SuppressWarnings("serial") - abstract static class BulkTask extends CountedCompleter { + abstract static class BulkTask extends CountedCompleter { Node[] tab; // same as Traverser Node next; TableStack stack, spare; @@ -5017,7 +5017,7 @@ private void recoverState(int n) { * simplest hoisted bypass to help avoid convoluted traps. */ @SuppressWarnings("serial") - static final class ForEachKeyTask + static final class ForEachKeyTask extends BulkTask { final Consumer action; ForEachKeyTask @@ -5044,7 +5044,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ForEachValueTask + static final class ForEachValueTask extends BulkTask { final Consumer action; ForEachValueTask @@ -5071,7 +5071,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ForEachEntryTask + static final class ForEachEntryTask extends BulkTask { final Consumer> action; ForEachEntryTask @@ -5098,7 +5098,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ForEachMappingTask + static final class ForEachMappingTask extends BulkTask { final BiConsumer action; ForEachMappingTask @@ -5125,7 +5125,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ForEachTransformedKeyTask + static final class ForEachTransformedKeyTask extends BulkTask { final Function transformer; final Consumer action; @@ -5158,7 +5158,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ForEachTransformedValueTask + static final class ForEachTransformedValueTask extends BulkTask { final Function transformer; final Consumer action; @@ -5191,7 +5191,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ForEachTransformedEntryTask + static final class ForEachTransformedEntryTask extends BulkTask { final Function, ? extends U> transformer; final Consumer action; @@ -5224,7 +5224,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ForEachTransformedMappingTask + static final class ForEachTransformedMappingTask extends BulkTask { final BiFunction transformer; final Consumer action; @@ -5258,7 +5258,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class SearchKeysTask + static final class SearchKeysTask extends BulkTask { final Function searchFunction; final AtomicReference result; @@ -5302,7 +5302,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class SearchValuesTask + static final class SearchValuesTask extends BulkTask { final Function searchFunction; final AtomicReference result; @@ -5346,7 +5346,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class SearchEntriesTask + static final class SearchEntriesTask extends BulkTask { final Function, ? extends U> searchFunction; final AtomicReference result; @@ -5390,7 +5390,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class SearchMappingsTask + static final class SearchMappingsTask extends BulkTask { final BiFunction searchFunction; final AtomicReference result; @@ -5434,7 +5434,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ReduceKeysTask + static final class ReduceKeysTask extends BulkTask { final BiFunction reducer; K result; @@ -5482,7 +5482,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ReduceValuesTask + static final class ReduceValuesTask extends BulkTask { final BiFunction reducer; V result; @@ -5530,7 +5530,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class ReduceEntriesTask + static final class ReduceEntriesTask extends BulkTask> { final BiFunction, Map.Entry, ? extends Map.Entry> reducer; Map.Entry result; @@ -5576,7 +5576,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceKeysTask + static final class MapReduceKeysTask extends BulkTask { final Function transformer; final BiFunction reducer; @@ -5630,7 +5630,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceValuesTask + static final class MapReduceValuesTask extends BulkTask { final Function transformer; final BiFunction reducer; @@ -5684,7 +5684,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceEntriesTask + static final class MapReduceEntriesTask extends BulkTask { final Function, ? extends U> transformer; final BiFunction reducer; @@ -5738,7 +5738,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceMappingsTask + static final class MapReduceMappingsTask extends BulkTask { final BiFunction transformer; final BiFunction reducer; @@ -5792,7 +5792,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceKeysToDoubleTask + static final class MapReduceKeysToDoubleTask extends BulkTask { final ToDoubleFunction transformer; final DoubleBinaryOperator reducer; @@ -5842,7 +5842,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceValuesToDoubleTask + static final class MapReduceValuesToDoubleTask extends BulkTask { final ToDoubleFunction transformer; final DoubleBinaryOperator reducer; @@ -5892,7 +5892,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceEntriesToDoubleTask + static final class MapReduceEntriesToDoubleTask extends BulkTask { final ToDoubleFunction> transformer; final DoubleBinaryOperator reducer; @@ -5942,7 +5942,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceMappingsToDoubleTask + static final class MapReduceMappingsToDoubleTask extends BulkTask { final ToDoubleBiFunction transformer; final DoubleBinaryOperator reducer; @@ -5992,7 +5992,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceKeysToLongTask + static final class MapReduceKeysToLongTask extends BulkTask { final ToLongFunction transformer; final LongBinaryOperator reducer; @@ -6042,7 +6042,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceValuesToLongTask + static final class MapReduceValuesToLongTask extends BulkTask { final ToLongFunction transformer; final LongBinaryOperator reducer; @@ -6092,7 +6092,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceEntriesToLongTask + static final class MapReduceEntriesToLongTask extends BulkTask { final ToLongFunction> transformer; final LongBinaryOperator reducer; @@ -6142,7 +6142,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceMappingsToLongTask + static final class MapReduceMappingsToLongTask extends BulkTask { final ToLongBiFunction transformer; final LongBinaryOperator reducer; @@ -6192,7 +6192,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceKeysToIntTask + static final class MapReduceKeysToIntTask extends BulkTask { final ToIntFunction transformer; final IntBinaryOperator reducer; @@ -6242,7 +6242,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceValuesToIntTask + static final class MapReduceValuesToIntTask extends BulkTask { final ToIntFunction transformer; final IntBinaryOperator reducer; @@ -6292,7 +6292,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceEntriesToIntTask + static final class MapReduceEntriesToIntTask extends BulkTask { final ToIntFunction> transformer; final IntBinaryOperator reducer; @@ -6342,7 +6342,7 @@ public final void compute() { } @SuppressWarnings("serial") - static final class MapReduceMappingsToIntTask + static final class MapReduceMappingsToIntTask extends BulkTask { final ToIntBiFunction transformer; final IntBinaryOperator reducer;