ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/extra166y/CustomConcurrentHashMap.java
(Generate patch)

Comparing jsr166/src/extra166y/CustomConcurrentHashMap.java (file contents):
Revision 1.26 by jsr166, Wed Jan 16 00:51:11 2013 UTC vs.
Revision 1.37 by jsr166, Sun Sep 13 16:28:13 2015 UTC

# Line 5 | Line 5
5   */
6  
7   package extra166y;
8 +
9   import java.lang.ref.*;
10   import java.lang.reflect.*;
11   import java.io.*;
# Line 19 | Line 20 | import sun.misc.Unsafe;
20   * user-supplied computational methods for setting and updating
21   * values. In particular: <ul>
22   *
23 < *   <li> Identity-based, Equality-based or User-definable {@link
24 < *        Equivalence}-based comparisons controlling membership.
23 > *   <li>Identity-based, Equality-based or User-definable {@link
24 > *       Equivalence}-based comparisons controlling membership.
25   *
26 < *   <li> {@linkplain SoftReference Soft}, {@linkplain
27 < *        WeakReference weak} or strong (regular) keys and values.
26 > *   <li>{@linkplain SoftReference Soft}, {@linkplain
27 > *       WeakReference weak} or strong (regular) keys and values.
28   *
29 < *   <li> User-definable {@code MappingFunctions} that may be
30 < *        used in method {@link
31 < *        CustomConcurrentHashMap#computeIfAbsent} to atomically
32 < *        establish a computed value, along with
33 < *        {@code RemappingFunctions} that can be used in method
34 < *        {@link CustomConcurrentHashMap#compute} to atomically
35 < *        replace values.
29 > *   <li>User-definable {@code MappingFunctions} that may be
30 > *       used in method {@link
31 > *       CustomConcurrentHashMap#computeIfAbsent} to atomically
32 > *       establish a computed value, along with
33 > *       {@code RemappingFunctions} that can be used in method
34 > *       {@link CustomConcurrentHashMap#compute} to atomically
35 > *       replace values.
36   *
37 < *    <li>Factory methods returning specialized forms for {@code int}
38 < *        keys and/or values, that may be more space-efficient
37 > *   <li>Factory methods returning specialized forms for {@code int}
38 > *       keys and/or values, that may be more space-efficient
39   *
40   * </ul>
41   *
# Line 110 | Line 111 | import sun.misc.Unsafe;
111   * @param <K> the type of keys maintained by this map
112   * @param <V> the type of mapped values
113   */
114 < public class CustomConcurrentHashMap<K, V> extends AbstractMap<K, V>
115 <    implements ConcurrentMap<K, V>, Serializable {
114 > public class CustomConcurrentHashMap<K,V> extends AbstractMap<K,V>
115 >    implements ConcurrentMap<K,V>, Serializable {
116      private static final long serialVersionUID = 7249069246764182397L;
117  
118      /*
# Line 224 | Line 225 | public class CustomConcurrentHashMap<K,
225  
226      /**
227       * A function computing a mapping from the given key to a value,
228 <     *  or {@code null} if there is no mapping.
228 >     * or {@code null} if there is no mapping.
229       */
230 <    public static interface MappingFunction<K, V> {
230 >    public static interface MappingFunction<K,V> {
231          /**
232           * Returns a value for the given key, or null if there is no
233           * mapping. If this function throws an (unchecked) exception,
# Line 245 | Line 246 | public class CustomConcurrentHashMap<K,
246      /**
247       * A function computing a new mapping from the given key and its
248       * current value to a new value, or {@code null} if there is
249 <     * no mapping
249 >     * no mapping.
250       */
251 <    public static interface RemappingFunction<K, V> {
251 >    public static interface RemappingFunction<K,V> {
252          /**
253           * Returns a new value for the given key and its current, or
254           * null if there is no mapping.
# Line 344 | Line 345 | public class CustomConcurrentHashMap<K,
345           * Records the linkage to be returned by the next call to getLinkage.
346           * @param linkage the linkage
347           */
348 <        void setLinkage(Node r);
348 >        void setLinkage(Node linkage);
349      }
350  
351      /**
352       * Each Segment holds a count and table corresponding to a segment
353       * of the table. This class contains only those methods for
354       * directly assigning these fields, which must only be called
355 <     * while holding locks
355 >     * while holding locks.
356       */
357      static final class Segment extends ReentrantLock {
358          volatile Node[] table;
# Line 386 | Line 387 | public class CustomConcurrentHashMap<K,
387          }
388  
389          /**
390 <         * See the similar code in ConcurrentHashMap for explanation
390 >         * See the similar code in ConcurrentHashMap for explanation.
391           */
392          final Node[] resizeTable(CustomConcurrentHashMap cchm) {
393              Node[] oldTable = table;
394              if (oldTable == null)
395 <                return table = (Node[])
395 <                    new Node[cchm.initialSegmentCapacity];
395 >                return table = new Node[cchm.initialSegmentCapacity];
396  
397              int oldCapacity = oldTable.length;
398              if (oldCapacity >= MAX_SEGMENT_CAPACITY)
399                  return oldTable;
400 <            Node[] newTable =
401 <                (Node[])new Node[oldCapacity<<1];
400 >            Node[] newTable = new Node[oldCapacity<<1];
401              int sizeMask = newTable.length - 1;
402              NodeFactory fac = cchm.factory;
403              for (int i = 0; i < oldCapacity ; i++) {
# Line 540 | Line 539 | public class CustomConcurrentHashMap<K,
539                  capacity = MAX_SEGMENT_CAPACITY;
540              this.initialSegmentCapacity = capacity;
541          }
542 <        this.segments = (Segment[])new Segment[NSEGMENTS];
542 >        this.segments = new Segment[NSEGMENTS];
543      }
544  
545      /**
# Line 681 | Line 680 | public class CustomConcurrentHashMap<K,
680       * Returns {@code true} if this map contains a key equivalent to
681       * the given key with respect to this map's key Equivalence.
682       *
683 <     * @param  key   possible key
683 >     * @param  key possible key
684       * @return {@code true} if this map contains the specified key
685       * @throws NullPointerException if the specified key is null
686       */
# Line 699 | Line 698 | public class CustomConcurrentHashMap<K,
698       * key with respect to this map's key Equivalence, or {@code null}
699       * if no such mapping exists.
700       *
701 <     * @param  key   possible key
702 <     * @return the value associated with the key or {@code null} if
703 <     * there is no mapping.
701 >     * @param  key possible key
702 >     * @return the value associated with the key, or {@code null} if
703 >     * there is no mapping
704       * @throws NullPointerException if the specified key is null
705       */
706      public V get(Object key) {
# Line 1092 | Line 1091 | public class CustomConcurrentHashMap<K,
1091       * @param mappingFunction the function to compute a value
1092       * @return the current (existing or computed) value associated with
1093       *         the specified key, or {@code null} if the computation
1094 <     *         returned {@code null}.
1094 >     *         returned {@code null}
1095       * @throws NullPointerException if the specified key or mappingFunction
1096 <     *         is null,
1096 >     *         is null
1097       * @throws RuntimeException or Error if the mappingFunction does so,
1098 <     *         in which case the mapping is left unestablished.
1098 >     *         in which case the mapping is left unestablished
1099       */
1100      public V computeIfAbsent(K key, MappingFunction<? super K, ? extends V> mappingFunction) {
1101          if (key == null || mappingFunction == null)
# Line 1167 | Line 1166 | public class CustomConcurrentHashMap<K,
1166       * @return the updated value or
1167       *         {@code null} if the computation returned {@code null}
1168       * @throws NullPointerException if the specified key or remappingFunction
1169 <     *         is null,
1169 >     *         is null
1170       * @throws RuntimeException or Error if the remappingFunction does so,
1171       *         in which case the mapping is left in its previous state
1172       */
# Line 1576 | Line 1575 | public class CustomConcurrentHashMap<K,
1575      private void readObject(java.io.ObjectInputStream s)
1576          throws IOException, ClassNotFoundException {
1577          s.defaultReadObject();
1578 <        this.segments = (Segment[])(new Segment[NSEGMENTS]);
1578 >        this.segments = new Segment[NSEGMENTS];
1579          for (;;) {
1580              K key = (K) s.readObject();
1581              V value = (V) s.readObject();
# Line 1722 | Line 1721 | public class CustomConcurrentHashMap<K,
1721       * to {@link java.lang.ref.Reference} constructors to arrange
1722       * removal of reclaimed nodes from maps via a background thread.
1723       * @return the reference queue associated with the background
1724 <     * cleanup thread.
1724 >     * cleanup thread
1725       */
1726      static ReferenceQueue<Object> getReclamationQueue() {
1727          ReferenceQueue<Object> q = refQueue;
# Line 1793 | Line 1792 | public class CustomConcurrentHashMap<K,
1792  
1793      // Strong Keys
1794  
1795 <    static abstract class StrongKeyNode implements Node {
1795 >    abstract static class StrongKeyNode implements Node {
1796          final Object key;
1797          final int locator;
1798          StrongKeyNode(int locator, Object key) {
# Line 1805 | Line 1804 | public class CustomConcurrentHashMap<K,
1804      }
1805  
1806  
1807 <    static abstract class StrongKeySelfValueNode
1807 >    abstract static class StrongKeySelfValueNode
1808          extends StrongKeyNode {
1809          StrongKeySelfValueNode(int locator, Object key) {
1810              super(locator, key);
# Line 1821 | Line 1820 | public class CustomConcurrentHashMap<K,
1820              super(locator, key);
1821          }
1822          public final Node getLinkage() { return null; }
1823 <        public final void setLinkage(Node r) { }
1823 >        public final void setLinkage(Node linkage) { }
1824      }
1825  
1826      static final class LinkedStrongKeySelfValueNode
# Line 1833 | Line 1832 | public class CustomConcurrentHashMap<K,
1832              this.linkage = linkage;
1833          }
1834          public final Node getLinkage() { return linkage; }
1835 <        public final void setLinkage(Node r) { linkage = r; }
1835 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
1836      }
1837  
1838      static final class StrongKeySelfValueNodeFactory
# Line 1852 | Line 1851 | public class CustomConcurrentHashMap<K,
1851          }
1852      }
1853  
1854 <    static abstract class StrongKeyStrongValueNode
1854 >    abstract static class StrongKeyStrongValueNode
1855          extends StrongKeyNode {
1856          volatile Object value;
1857          StrongKeyStrongValueNode(int locator, Object key, Object value) {
# Line 1871 | Line 1870 | public class CustomConcurrentHashMap<K,
1870              super(locator, key, value);
1871          }
1872          public final Node getLinkage() { return null; }
1873 <        public final void setLinkage(Node r) { }
1873 >        public final void setLinkage(Node linkage) { }
1874      }
1875  
1876      static final class LinkedStrongKeyStrongValueNode
# Line 1884 | Line 1883 | public class CustomConcurrentHashMap<K,
1883              this.linkage = linkage;
1884          }
1885          public final Node getLinkage() { return linkage; }
1886 <        public final void setLinkage(Node r) { linkage = r; }
1886 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
1887      }
1888  
1889      static final class StrongKeyStrongValueNodeFactory
# Line 1905 | Line 1904 | public class CustomConcurrentHashMap<K,
1904  
1905      // ...
1906  
1907 <    static abstract class StrongKeyIntValueNode
1907 >    abstract static class StrongKeyIntValueNode
1908          extends StrongKeyNode {
1909          volatile int value;
1910          StrongKeyIntValueNode(int locator, Object key, Object value) {
# Line 1926 | Line 1925 | public class CustomConcurrentHashMap<K,
1925              super(locator, key, value);
1926          }
1927          public final Node getLinkage() { return null; }
1928 <        public final void setLinkage(Node r) { }
1928 >        public final void setLinkage(Node linkage) { }
1929      }
1930  
1931      static final class LinkedStrongKeyIntValueNode
# Line 1939 | Line 1938 | public class CustomConcurrentHashMap<K,
1938              this.linkage = linkage;
1939          }
1940          public final Node getLinkage() { return linkage; }
1941 <        public final void setLinkage(Node r) { linkage = r; }
1941 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
1942      }
1943  
1944      static final class StrongKeyIntValueNodeFactory
# Line 1960 | Line 1959 | public class CustomConcurrentHashMap<K,
1959  
1960      // ...
1961  
1962 <    static abstract class StrongKeyWeakValueNode
1962 >    abstract static class StrongKeyWeakValueNode
1963          extends StrongKeyNode {
1964          volatile EmbeddedWeakReference valueRef;
1965          final CustomConcurrentHashMap cchm;
# Line 1994 | Line 1993 | public class CustomConcurrentHashMap<K,
1993              super(locator, key, value, cchm);
1994          }
1995          public final Node getLinkage() { return null; }
1996 <        public final void setLinkage(Node r) { }
1996 >        public final void setLinkage(Node linkage) { }
1997      }
1998  
1999      static final class LinkedStrongKeyWeakValueNode
# Line 2008 | Line 2007 | public class CustomConcurrentHashMap<K,
2007              this.linkage = linkage;
2008          }
2009          public final Node getLinkage() { return linkage; }
2010 <        public final void setLinkage(Node r) { linkage = r; }
2010 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2011      }
2012  
2013      static final class StrongKeyWeakValueNodeFactory
# Line 2028 | Line 2027 | public class CustomConcurrentHashMap<K,
2027      }
2028  
2029  
2030 <    static abstract class StrongKeySoftValueNode
2030 >    abstract static class StrongKeySoftValueNode
2031          extends StrongKeyNode {
2032          volatile EmbeddedSoftReference valueRef;
2033          final CustomConcurrentHashMap cchm;
# Line 2062 | Line 2061 | public class CustomConcurrentHashMap<K,
2061              super(locator, key, value, cchm);
2062          }
2063          public final Node getLinkage() { return null; }
2064 <        public final void setLinkage(Node r) { }
2064 >        public final void setLinkage(Node linkage) { }
2065      }
2066  
2067      static final class LinkedStrongKeySoftValueNode
# Line 2076 | Line 2075 | public class CustomConcurrentHashMap<K,
2075              this.linkage = linkage;
2076          }
2077          public final Node getLinkage() { return linkage; }
2078 <        public final void setLinkage(Node r) { linkage = r; }
2078 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2079      }
2080  
2081      static final class StrongKeySoftValueNodeFactory
# Line 2097 | Line 2096 | public class CustomConcurrentHashMap<K,
2096  
2097      // Weak keys
2098  
2099 <    static abstract class WeakKeyNode extends WeakReference
2099 >    abstract static class WeakKeyNode extends WeakReference
2100          implements Node {
2101          final int locator;
2102          final CustomConcurrentHashMap cchm;
# Line 2113 | Line 2112 | public class CustomConcurrentHashMap<K,
2112          }
2113      }
2114  
2115 <    static abstract class WeakKeySelfValueNode
2115 >    abstract static class WeakKeySelfValueNode
2116          extends WeakKeyNode {
2117          WeakKeySelfValueNode(int locator, Object key,
2118                               CustomConcurrentHashMap cchm) {
# Line 2130 | Line 2129 | public class CustomConcurrentHashMap<K,
2129              super(locator, key, cchm);
2130          }
2131          public final Node getLinkage() { return null; }
2132 <        public final void setLinkage(Node r) { }
2132 >        public final void setLinkage(Node linkage) { }
2133      }
2134  
2135      static final class LinkedWeakKeySelfValueNode
# Line 2143 | Line 2142 | public class CustomConcurrentHashMap<K,
2142              this.linkage = linkage;
2143          }
2144          public final Node getLinkage() { return linkage; }
2145 <        public final void setLinkage(Node r) { linkage = r; }
2145 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2146      }
2147  
2148      static final class WeakKeySelfValueNodeFactory
# Line 2163 | Line 2162 | public class CustomConcurrentHashMap<K,
2162      }
2163  
2164  
2165 <    static abstract class WeakKeyStrongValueNode
2165 >    abstract static class WeakKeyStrongValueNode
2166          extends WeakKeyNode {
2167          volatile Object value;
2168          WeakKeyStrongValueNode(int locator, Object key, Object value,
# Line 2183 | Line 2182 | public class CustomConcurrentHashMap<K,
2182              super(locator, key, value, cchm);
2183          }
2184          public final Node getLinkage() { return null; }
2185 <        public final void setLinkage(Node r) { }
2185 >        public final void setLinkage(Node linkage) { }
2186      }
2187  
2188      static final class LinkedWeakKeyStrongValueNode
# Line 2197 | Line 2196 | public class CustomConcurrentHashMap<K,
2196              this.linkage = linkage;
2197          }
2198          public final Node getLinkage() { return linkage; }
2199 <        public final void setLinkage(Node r) { linkage = r; }
2199 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2200      }
2201  
2202      static final class WeakKeyStrongValueNodeFactory
# Line 2216 | Line 2215 | public class CustomConcurrentHashMap<K,
2215          }
2216      }
2217  
2218 <    static abstract class WeakKeyIntValueNode
2218 >    abstract static class WeakKeyIntValueNode
2219          extends WeakKeyNode {
2220          volatile int value;
2221          WeakKeyIntValueNode(int locator, Object key, Object value,
# Line 2238 | Line 2237 | public class CustomConcurrentHashMap<K,
2237              super(locator, key, value, cchm);
2238          }
2239          public final Node getLinkage() { return null; }
2240 <        public final void setLinkage(Node r) { }
2240 >        public final void setLinkage(Node linkage) { }
2241      }
2242  
2243      static final class LinkedWeakKeyIntValueNode
# Line 2252 | Line 2251 | public class CustomConcurrentHashMap<K,
2251              this.linkage = linkage;
2252          }
2253          public final Node getLinkage() { return linkage; }
2254 <        public final void setLinkage(Node r) { linkage = r; }
2254 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2255      }
2256  
2257      static final class WeakKeyIntValueNodeFactory
# Line 2271 | Line 2270 | public class CustomConcurrentHashMap<K,
2270          }
2271      }
2272  
2273 <    static abstract class WeakKeyWeakValueNode
2273 >    abstract static class WeakKeyWeakValueNode
2274          extends WeakKeyNode {
2275          volatile EmbeddedWeakReference valueRef;
2276          WeakKeyWeakValueNode(int locator, Object key, Object value,
# Line 2300 | Line 2299 | public class CustomConcurrentHashMap<K,
2299              super(locator, key, value, cchm);
2300          }
2301          public final Node getLinkage() { return null; }
2302 <        public final void setLinkage(Node r) { }
2302 >        public final void setLinkage(Node linkage) { }
2303      }
2304  
2305      static final class LinkedWeakKeyWeakValueNode
# Line 2314 | Line 2313 | public class CustomConcurrentHashMap<K,
2313              this.linkage = linkage;
2314          }
2315          public final Node getLinkage() { return linkage; }
2316 <        public final void setLinkage(Node r) { linkage = r; }
2316 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2317      }
2318  
2319      static final class WeakKeyWeakValueNodeFactory
# Line 2334 | Line 2333 | public class CustomConcurrentHashMap<K,
2333      }
2334  
2335  
2336 <    static abstract class WeakKeySoftValueNode
2336 >    abstract static class WeakKeySoftValueNode
2337          extends WeakKeyNode {
2338          volatile EmbeddedSoftReference valueRef;
2339          WeakKeySoftValueNode(int locator, Object key, Object value,
# Line 2363 | Line 2362 | public class CustomConcurrentHashMap<K,
2362              super(locator, key, value, cchm);
2363          }
2364          public final Node getLinkage() { return null; }
2365 <        public final void setLinkage(Node r) { }
2365 >        public final void setLinkage(Node linkage) { }
2366      }
2367  
2368      static final class LinkedWeakKeySoftValueNode
# Line 2377 | Line 2376 | public class CustomConcurrentHashMap<K,
2376              this.linkage = linkage;
2377          }
2378          public final Node getLinkage() { return linkage; }
2379 <        public final void setLinkage(Node r) { linkage = r; }
2379 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2380      }
2381  
2382      static final class WeakKeySoftValueNodeFactory
# Line 2398 | Line 2397 | public class CustomConcurrentHashMap<K,
2397  
2398      // Soft keys
2399  
2400 <    static abstract class SoftKeyNode extends SoftReference
2400 >    abstract static class SoftKeyNode extends SoftReference
2401          implements Node {
2402          final int locator;
2403          final CustomConcurrentHashMap cchm;
# Line 2414 | Line 2413 | public class CustomConcurrentHashMap<K,
2413          }
2414      }
2415  
2416 <    static abstract class SoftKeySelfValueNode
2416 >    abstract static class SoftKeySelfValueNode
2417          extends SoftKeyNode {
2418          SoftKeySelfValueNode(int locator, Object key,
2419                               CustomConcurrentHashMap cchm) {
# Line 2431 | Line 2430 | public class CustomConcurrentHashMap<K,
2430              super(locator, key, cchm);
2431          }
2432          public final Node getLinkage() { return null; }
2433 <        public final void setLinkage(Node r) { }
2433 >        public final void setLinkage(Node linkage) { }
2434      }
2435  
2436      static final class LinkedSoftKeySelfValueNode
# Line 2444 | Line 2443 | public class CustomConcurrentHashMap<K,
2443              this.linkage = linkage;
2444          }
2445          public final Node getLinkage() { return linkage; }
2446 <        public final void setLinkage(Node r) { linkage = r; }
2446 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2447      }
2448  
2449      static final class SoftKeySelfValueNodeFactory
# Line 2464 | Line 2463 | public class CustomConcurrentHashMap<K,
2463      }
2464  
2465  
2466 <    static abstract class SoftKeyStrongValueNode
2466 >    abstract static class SoftKeyStrongValueNode
2467          extends SoftKeyNode {
2468          volatile Object value;
2469          SoftKeyStrongValueNode(int locator, Object key, Object value,
# Line 2484 | Line 2483 | public class CustomConcurrentHashMap<K,
2483              super(locator, key, value, cchm);
2484          }
2485          public final Node getLinkage() { return null; }
2486 <        public final void setLinkage(Node r) { }
2486 >        public final void setLinkage(Node linkage) { }
2487      }
2488  
2489      static final class LinkedSoftKeyStrongValueNode
# Line 2498 | Line 2497 | public class CustomConcurrentHashMap<K,
2497              this.linkage = linkage;
2498          }
2499          public final Node getLinkage() { return linkage; }
2500 <        public final void setLinkage(Node r) { linkage = r; }
2500 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2501      }
2502  
2503      static final class SoftKeyStrongValueNodeFactory
# Line 2517 | Line 2516 | public class CustomConcurrentHashMap<K,
2516          }
2517      }
2518  
2519 <    static abstract class SoftKeyIntValueNode
2519 >    abstract static class SoftKeyIntValueNode
2520          extends SoftKeyNode {
2521          volatile int value;
2522          SoftKeyIntValueNode(int locator, Object key, Object value,
# Line 2539 | Line 2538 | public class CustomConcurrentHashMap<K,
2538              super(locator, key, value, cchm);
2539          }
2540          public final Node getLinkage() { return null; }
2541 <        public final void setLinkage(Node r) { }
2541 >        public final void setLinkage(Node linkage) { }
2542      }
2543  
2544      static final class LinkedSoftKeyIntValueNode
# Line 2553 | Line 2552 | public class CustomConcurrentHashMap<K,
2552              this.linkage = linkage;
2553          }
2554          public final Node getLinkage() { return linkage; }
2555 <        public final void setLinkage(Node r) { linkage = r; }
2555 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2556      }
2557  
2558      static final class SoftKeyIntValueNodeFactory
# Line 2572 | Line 2571 | public class CustomConcurrentHashMap<K,
2571          }
2572      }
2573  
2574 <    static abstract class SoftKeyWeakValueNode
2574 >    abstract static class SoftKeyWeakValueNode
2575          extends SoftKeyNode {
2576          volatile EmbeddedWeakReference valueRef;
2577          SoftKeyWeakValueNode(int locator, Object key, Object value,
# Line 2601 | Line 2600 | public class CustomConcurrentHashMap<K,
2600              super(locator, key, value, cchm);
2601          }
2602          public final Node getLinkage() { return null; }
2603 <        public final void setLinkage(Node r) { }
2603 >        public final void setLinkage(Node linkage) { }
2604      }
2605  
2606      static final class LinkedSoftKeyWeakValueNode
# Line 2615 | Line 2614 | public class CustomConcurrentHashMap<K,
2614              this.linkage = linkage;
2615          }
2616          public final Node getLinkage() { return linkage; }
2617 <        public final void setLinkage(Node r) { linkage = r; }
2617 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2618      }
2619  
2620      static final class SoftKeyWeakValueNodeFactory
# Line 2635 | Line 2634 | public class CustomConcurrentHashMap<K,
2634      }
2635  
2636  
2637 <    static abstract class SoftKeySoftValueNode
2637 >    abstract static class SoftKeySoftValueNode
2638          extends SoftKeyNode {
2639          volatile EmbeddedSoftReference valueRef;
2640          SoftKeySoftValueNode(int locator, Object key, Object value,
# Line 2664 | Line 2663 | public class CustomConcurrentHashMap<K,
2663              super(locator, key, value, cchm);
2664          }
2665          public final Node getLinkage() { return null; }
2666 <        public final void setLinkage(Node r) { }
2666 >        public final void setLinkage(Node linkage) { }
2667      }
2668  
2669      static final class LinkedSoftKeySoftValueNode
# Line 2678 | Line 2677 | public class CustomConcurrentHashMap<K,
2677              this.linkage = linkage;
2678          }
2679          public final Node getLinkage() { return linkage; }
2680 <        public final void setLinkage(Node r) { linkage = r; }
2680 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2681      }
2682  
2683      static final class SoftKeySoftValueNodeFactory
# Line 2697 | Line 2696 | public class CustomConcurrentHashMap<K,
2696          }
2697      }
2698  
2699 <    static abstract class IntKeyNode implements Node {
2699 >    abstract static class IntKeyNode implements Node {
2700          final int key;
2701          IntKeyNode(int locator, Object key) {
2702              this.key = ((Integer)key).intValue();
# Line 2707 | Line 2706 | public class CustomConcurrentHashMap<K,
2706      }
2707  
2708  
2709 <    static abstract class IntKeySelfValueNode
2709 >    abstract static class IntKeySelfValueNode
2710          extends IntKeyNode {
2711          IntKeySelfValueNode(int locator, Object key) {
2712              super(locator, key);
# Line 2723 | Line 2722 | public class CustomConcurrentHashMap<K,
2722              super(locator, key);
2723          }
2724          public final Node getLinkage() { return null; }
2725 <        public final void setLinkage(Node r) { }
2725 >        public final void setLinkage(Node linkage) { }
2726      }
2727  
2728      static final class LinkedIntKeySelfValueNode
# Line 2735 | Line 2734 | public class CustomConcurrentHashMap<K,
2734              this.linkage = linkage;
2735          }
2736          public final Node getLinkage() { return linkage; }
2737 <        public final void setLinkage(Node r) { linkage = r; }
2737 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2738      }
2739  
2740      static final class IntKeySelfValueNodeFactory
# Line 2754 | Line 2753 | public class CustomConcurrentHashMap<K,
2753          }
2754      }
2755  
2756 <    static abstract class IntKeyStrongValueNode
2756 >    abstract static class IntKeyStrongValueNode
2757          extends IntKeyNode {
2758          volatile Object value;
2759          IntKeyStrongValueNode(int locator, Object key, Object value) {
# Line 2773 | Line 2772 | public class CustomConcurrentHashMap<K,
2772              super(locator, key, value);
2773          }
2774          public final Node getLinkage() { return null; }
2775 <        public final void setLinkage(Node r) { }
2775 >        public final void setLinkage(Node linkage) { }
2776      }
2777  
2778      static final class LinkedIntKeyStrongValueNode
# Line 2786 | Line 2785 | public class CustomConcurrentHashMap<K,
2785              this.linkage = linkage;
2786          }
2787          public final Node getLinkage() { return linkage; }
2788 <        public final void setLinkage(Node r) { linkage = r; }
2788 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2789      }
2790  
2791      static final class IntKeyStrongValueNodeFactory
# Line 2805 | Line 2804 | public class CustomConcurrentHashMap<K,
2804          }
2805      }
2806  
2807 <    static abstract class IntKeyIntValueNode
2807 >    abstract static class IntKeyIntValueNode
2808          extends IntKeyNode {
2809          volatile int value;
2810          IntKeyIntValueNode(int locator, Object key, Object value) {
# Line 2826 | Line 2825 | public class CustomConcurrentHashMap<K,
2825              super(locator, key, value);
2826          }
2827          public final Node getLinkage() { return null; }
2828 <        public final void setLinkage(Node r) { }
2828 >        public final void setLinkage(Node linkage) { }
2829      }
2830  
2831      static final class LinkedIntKeyIntValueNode
# Line 2839 | Line 2838 | public class CustomConcurrentHashMap<K,
2838              this.linkage = linkage;
2839          }
2840          public final Node getLinkage() { return linkage; }
2841 <        public final void setLinkage(Node r) { linkage = r; }
2841 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2842      }
2843  
2844      static final class IntKeyIntValueNodeFactory
# Line 2858 | Line 2857 | public class CustomConcurrentHashMap<K,
2857          }
2858      }
2859  
2860 <    static abstract class IntKeyWeakValueNode
2860 >    abstract static class IntKeyWeakValueNode
2861          extends IntKeyNode {
2862          volatile EmbeddedWeakReference valueRef;
2863          final CustomConcurrentHashMap cchm;
# Line 2892 | Line 2891 | public class CustomConcurrentHashMap<K,
2891              super(locator, key, value, cchm);
2892          }
2893          public final Node getLinkage() { return null; }
2894 <        public final void setLinkage(Node r) { }
2894 >        public final void setLinkage(Node linkage) { }
2895      }
2896  
2897      static final class LinkedIntKeyWeakValueNode
# Line 2906 | Line 2905 | public class CustomConcurrentHashMap<K,
2905              this.linkage = linkage;
2906          }
2907          public final Node getLinkage() { return linkage; }
2908 <        public final void setLinkage(Node r) { linkage = r; }
2908 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2909      }
2910  
2911      static final class IntKeyWeakValueNodeFactory
# Line 2926 | Line 2925 | public class CustomConcurrentHashMap<K,
2925      }
2926  
2927  
2928 <    static abstract class IntKeySoftValueNode
2928 >    abstract static class IntKeySoftValueNode
2929          extends IntKeyNode {
2930          volatile EmbeddedSoftReference valueRef;
2931          final CustomConcurrentHashMap cchm;
# Line 2960 | Line 2959 | public class CustomConcurrentHashMap<K,
2959              super(locator, key, value, cchm);
2960          }
2961          public final Node getLinkage() { return null; }
2962 <        public final void setLinkage(Node r) { }
2962 >        public final void setLinkage(Node linkage) { }
2963      }
2964  
2965      static final class LinkedIntKeySoftValueNode
# Line 2974 | Line 2973 | public class CustomConcurrentHashMap<K,
2973              this.linkage = linkage;
2974          }
2975          public final Node getLinkage() { return linkage; }
2976 <        public final void setLinkage(Node r) { linkage = r; }
2976 >        public final void setLinkage(Node linkage) { this.linkage = linkage; }
2977      }
2978  
2979      static final class IntKeySoftValueNodeFactory
# Line 3007 | Line 3006 | public class CustomConcurrentHashMap<K,
3006          try {
3007              UNSAFE = getUnsafe();
3008              tableBase = UNSAFE.arrayBaseOffset(Node[].class);
3009 <            int s = UNSAFE.arrayIndexScale(Node[].class);
3010 <            if ((s & (s-1)) != 0)
3009 >            int scale = UNSAFE.arrayIndexScale(Node[].class);
3010 >            if ((scale & (scale - 1)) != 0)
3011                  throw new Error("data type scale not a power of two");
3012 <            tableShift = 31 - Integer.numberOfLeadingZeros(s);
3012 >            tableShift = 31 - Integer.numberOfLeadingZeros(scale);
3013              segmentsBase = UNSAFE.arrayBaseOffset(Segment[].class);
3014 <            s = UNSAFE.arrayIndexScale(Segment[].class);
3015 <            if ((s & (s-1)) != 0)
3014 >            scale = UNSAFE.arrayIndexScale(Segment[].class);
3015 >            if ((scale & (scale - 1)) != 0)
3016                  throw new Error("data type scale not a power of two");
3017 <            segmentsShift = 31 - Integer.numberOfLeadingZeros(s);
3017 >            segmentsShift = 31 - Integer.numberOfLeadingZeros(scale);
3018          } catch (Throwable e) {
3019              throw new RuntimeException("Could not initialize intrinsics", e);
3020          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines