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.2 by dl, Tue Jun 30 14:56:53 2009 UTC vs.
Revision 1.14 by jsr166, Fri Oct 22 05:18:30 2010 UTC

# Line 31 | Line 31 | import sun.misc.Unsafe;
31   *        establish a computed value, along with
32   *        <code>RemappingFunctions</code> that can be used in method
33   *        {@link CustomConcurrentHashMap#compute} to atomically
34 < *        replace values.
34 > *        replace values.
35   *
36   *    <li>Factory methods returning specialized forms for <tt>int</tt>
37   *        keys and/or values, that may be more space-efficient
38   *
39   * </ul>
40 < *
40 > *
41   * Per-map settings are established in constructors, as in the
42   * following usages (that assume static imports to simplify expression
43   * of configuration parameters):
44 < *
44 > *
45   * <pre>
46   * {@code
47   * identityMap = new CustomConcurrentHashMap<Person,Salary>
# Line 53 | Line 53 | import sun.misc.Unsafe;
53   *     (STRONG,
54   *      new Equivalence<Person>() {
55   *          public boolean equal(Person k, Object x) {
56 < *            return x instanceOf Person && k.name.equals(((Person)x).name);
56 > *            return x instanceof Person && k.name.equals(((Person)x).name);
57   *          }
58 < *          public int hash(Object x) {
59 < *             return (x instanceOf Person)? ((Person)x).name.hashCode() : 0;
58 > *          public int hash(Object x) {
59 > *             return (x instanceof Person) ? ((Person)x).name.hashCode() : 0;
60   *          }
61   *        },
62   *      STRONG, EQUALS, 0);
# Line 69 | Line 69 | import sun.misc.Unsafe;
69   * and identity-based equality for keys. The third usage
70   * illustrates a map with a custom Equivalence that looks only at the
71   * name field of a (fictional) Person class.
72 < *
72 > *
73   * <p>This class also includes nested class {@link KeySet}
74   * that provides space-efficient Set views of maps, also supporting
75   * method <code>intern</code>, which may be of use in canonicalizing
# Line 81 | Line 81 | import sun.misc.Unsafe;
81   * via a background thread common across all maps. Because of the
82   * potential for asynchronous clearing of References, methods such as
83   * <code>containsValue</code> have weaker guarantees than you might
84 < * expect even in the absence of other explicity concurrent
84 > * expect even in the absence of other explicitly concurrent
85   * operations. For example <code>containsValue(value)</code> may
86   * return true even if <code>value</code> is no longer available upon
87   * return from the method.
# Line 126 | Line 126 | public class CustomConcurrentHashMap<K,
126       * Additionally, because Reference keys/values may become null
127       * asynchronously, we cannot ensure snapshot integrity in methods
128       * such as containsValue, so do not try to obtain them (so, no
129 <     * modCounts etc).
129 >     * modCounts etc).
130       *
131       * Also, the volatility of Segment count vs table fields are
132       * swapped, enabled by ensuring fences on new node assignments.
# Line 138 | Line 138 | public class CustomConcurrentHashMap<K,
138       * maps. strong denotes ordinary objects. weak and soft denote the
139       * corresponding {@link java.lang.ref.Reference} types.
140       */
141 <    public enum Strength {
141 >    public enum Strength {
142          strong("Strong"), weak("Weak"), soft("Soft");
143          private final String name;
144          Strength(String name) { this.name = name; }
145          String getName() { return name; }
146      };
147  
148 <    
148 >
149      /** The strength of ordinary references */
150      public static final Strength STRONG = Strength.strong;
151  
# Line 184 | Line 184 | public class CustomConcurrentHashMap<K,
184           */
185          boolean equal(K key, Object x);
186          /**
187 <         * Returns a hash value such that equal(a, b) implies
187 >         * Returns a hash value such that equal(a, b) implies
188           * hash(a)==hash(b).
189           * @param x an object queried for membership
190           * @return a hash value
# Line 194 | Line 194 | public class CustomConcurrentHashMap<K,
194  
195      // builtin equivalences
196  
197 <    static final class EquivalenceUsingIdentity
197 >    static final class EquivalenceUsingIdentity
198          implements Equivalence<Object>, Serializable {
199          private static final long serialVersionUID = 7259069246764182397L;
200          public final boolean equal(Object a, Object b) { return a == b; }
201          public final int hash(Object a) { return System.identityHashCode(a); }
202      }
203  
204 <    static final class EquivalenceUsingEquals
204 >    static final class EquivalenceUsingEquals
205          implements Equivalence<Object>, Serializable {
206          private static final long serialVersionUID = 7259069247764182397L;
207          public final boolean equal(Object a, Object b) { return a.equals(b); }
# Line 212 | Line 212 | public class CustomConcurrentHashMap<K,
212       * An Equivalence object performing identity-based comparisons
213       * and using {@link System#identityHashCode} for hashing
214       */
215 <    public static final Equivalence<Object> IDENTITY =
215 >    public static final Equivalence<Object> IDENTITY =
216          new EquivalenceUsingIdentity();
217 <    
217 >
218      /**
219       * An Equivalence object performing {@link Object#equals} based comparisons
220       * and using {@link Object#hashCode} hashing
221       */
222 <    public static final Equivalence<Object> EQUALS =
222 >    public static final Equivalence<Object> EQUALS =
223          new EquivalenceUsingEquals();
224  
225      /**
226       * A function computing a mapping from the given key to a value,
227 <     *  or <code>null</code> if there is no mapping.
227 >     *  or <code>null</code> if there is no mapping.
228       */
229      public static interface MappingFunction<K, V> {
230          /**
# Line 275 | Line 275 | public class CustomConcurrentHashMap<K,
275       */
276      static interface NodeFactory extends Serializable {
277          /**
278 <         * Creates and returns a Node using the given parameters
278 >         * Creates and returns a Node using the given parameters.
279 >         *
280           * @param locator an opaque immutable locator for this node
281 <         * @parem key the (nonnull) immutable key
282 <         * @parem value the (nonnull) volatile value;
283 <         * @param cchm the table creating this node.
281 >         * @param key the (non-null) immutable key
282 >         * @param value the (non-null) volatile value
283 >         * @param cchm the table creating this node
284           * @param linkage an opaque volatile linkage for maintaining this node
285           */
286 <        Node newNode(int locator, Object key, Object value,
286 >        Node newNode(int locator, Object key, Object value,
287                       CustomConcurrentHashMap cchm, Node linkage);
288      }
289  
# Line 303 | Line 304 | public class CustomConcurrentHashMap<K,
304      static interface Node extends Reclaimable {
305          /**
306           * Returns the key established during the creation of this node.
307 <         * Note: This method is named "get" rether than "getKey"
307 >         * Note: This method is named "get" rather than "getKey"
308           * to simplify usage of Reference keys.
309           * @return the key
310           */
# Line 332 | Line 333 | public class CustomConcurrentHashMap<K,
333          void setValue(Object value);
334  
335          /**
336 <         * Returns the lonkage established during the creation of this
336 >         * Returns the linkage established during the creation of this
337           * node or, if since updated, the linkage set by the most
338           * recent call to setLinkage.
339           * @return the linkage
# Line 355 | Line 356 | public class CustomConcurrentHashMap<K,
356      static final class Segment extends ReentrantLock {
357          volatile Node[] table;
358          int count;
359 <        
359 >
360          final void decrementCount() {
361              if (--count == 0)
362                  table = null;
# Line 396 | Line 397 | public class CustomConcurrentHashMap<K,
397              int oldCapacity = oldTable.length;
398              if (oldCapacity >= MAX_SEGMENT_CAPACITY)
399                  return oldTable;
400 <            Node[] newTable =
400 >            Node[] newTable =
401                  (Node[])new Node[oldCapacity<<1];
402              int sizeMask = newTable.length - 1;
403              NodeFactory fac = cchm.factory;
# Line 436 | Line 437 | public class CustomConcurrentHashMap<K,
437                                  (pv = p.getValue()) == null)
438                                  --count;
439                              else
440 <                                newTable[k] =
440 >                                newTable[k] =
441                                      fac.newNode(ph, pk, pv, cchm, newTable[k]);
442                          }
443                      }
# Line 477 | Line 478 | public class CustomConcurrentHashMap<K,
478       * The segments, each of which acts as a hash table
479       */
480      transient volatile Segment[] segments;
481 <    
481 >
482      /**
483       * The factory for this map
484       */
485      final NodeFactory factory;
486 <    
486 >
487      /**
488       * Equivalence object for keys
489       */
490      final Equivalence<? super K> keyEquivalence;
491 <    
491 >
492      /**
493       * Equivalence object for values
494       */
495      final Equivalence<? super V> valueEquivalence;
496 <    
496 >
497      /**
498       * The initial size of Segment tables when they are first constructed
499       */
# Line 515 | Line 516 | public class CustomConcurrentHashMap<K,
516          this.keyEquivalence = keq;
517          this.valueEquivalence = veq;
518          // Reflectively assemble factory name
519 <        String factoryName =
520 <            CustomConcurrentHashMap.class.getName() + "$" +
521 <            ks + "Key" +
519 >        String factoryName =
520 >            CustomConcurrentHashMap.class.getName() + "$" +
521 >            ks + "Key" +
522              vs + "ValueNodeFactory";
523          try {
524              this.factory = (NodeFactory)
# Line 532 | Line 533 | public class CustomConcurrentHashMap<K,
533              int sc = (int)((1L + (4L * es) / 3) >>> SEGMENT_BITS);
534              if (sc < MIN_SEGMENT_CAPACITY)
535                  sc = MIN_SEGMENT_CAPACITY;
536 <            else if (sc > MAX_SEGMENT_CAPACITY)
537 <                sc = MAX_SEGMENT_CAPACITY;
538 <            this.initialSegmentCapacity = sc;
536 >            int capacity = MIN_SEGMENT_CAPACITY; // ensure power of two
537 >            while (capacity < sc)
538 >                capacity <<= 1;
539 >            if (capacity > MAX_SEGMENT_CAPACITY)
540 >                capacity = MAX_SEGMENT_CAPACITY;
541 >            this.initialSegmentCapacity = capacity;
542          }
543          this.segments = (Segment[])new Segment[NSEGMENTS];
544      }
# Line 554 | Line 558 | public class CustomConcurrentHashMap<K,
558                                     Strength valueStrength,
559                                     Equivalence<? super V> valueEquivalence,
560                                     int expectedSize) {
561 <        this(keyStrength.getName(), keyEquivalence,
561 >        this(keyStrength.getName(), keyEquivalence,
562               valueStrength.getName(), valueEquivalence,
563               expectedSize);
564      }
# Line 600 | Line 604 | public class CustomConcurrentHashMap<K,
604                         Equivalence<? super KeyType> keyEquivalence,
605                         int expectedSize) {
606          return new CustomConcurrentHashMap<KeyType, Integer>
607 <            (keyStrength.getName(), keyEquivalence, INT_STRING, EQUALS,
607 >            (keyStrength.getName(), keyEquivalence, INT_STRING, EQUALS,
608               expectedSize);
609      }
610  
# Line 614 | Line 618 | public class CustomConcurrentHashMap<K,
618      public static CustomConcurrentHashMap<Integer, Integer>
619          newIntKeyIntValueMap(int expectedSize) {
620          return new CustomConcurrentHashMap<Integer, Integer>
621 <            (INT_STRING, EQUALS, INT_STRING, EQUALS,
621 >            (INT_STRING, EQUALS, INT_STRING, EQUALS,
622               expectedSize);
623      }
624  
# Line 629 | Line 633 | public class CustomConcurrentHashMap<K,
633  
634      /**
635       * Returns the segment for possibly inserting into the table
636 <     * associated with given hash, constructing it if necesary.
636 >     * associated with given hash, constructing it if necessary.
637       * @param hash the hash code for the key
638       * @return the segment
639       */
# Line 638 | Line 642 | public class CustomConcurrentHashMap<K,
642          int index = (hash >>> SEGMENT_SHIFT) & SEGMENT_MASK;
643          Segment seg = segs[index];
644          if (seg == null) {
645 <            synchronized(segs) {
645 >            synchronized (segs) {
646                  seg = segs[index];
647                  if (seg == null) {
648                      seg = new Segment();
# Line 662 | Line 666 | public class CustomConcurrentHashMap<K,
666                  while (p != null) {
667                      Object k = p.get();
668                      if (k == key ||
669 <                        (k != null &&
670 <                         p.getLocator() == hash &&
669 >                        (k != null &&
670 >                         p.getLocator() == hash &&
671                           keyEquivalence.equal((K)k, key)))
672                          return p;
673                      p = p.getLinkage();
# Line 696 | Line 700 | public class CustomConcurrentHashMap<K,
700       * if no such mapping exists
701       *
702       * @param  key   possible key
703 <     * @return the value associated with the kew or <tt>null</tt> if
703 >     * @return the value associated with the key or <tt>null</tt> if
704       * there is no mapping.
705       * @throws NullPointerException if the specified key is null
706       */
# Line 712 | Line 716 | public class CustomConcurrentHashMap<K,
716      }
717  
718      /**
719 <     * Share dimplementation for put, putIfAbsent
719 >     * Shared implementation for put, putIfAbsent
720       */
721      final V doPut(K key, V value, boolean onlyIfNull) {
722          if (key == null || value == null)
# Line 824 | Line 828 | public class CustomConcurrentHashMap<K,
828                  Node r = findNode(key, hash, seg);
829                  if (r != null) {
830                      V v = (V)(r.getValue());
831 <                    if (v == oldValue ||
831 >                    if (v == oldValue ||
832                          (v != null && valueEquivalence.equal(v, oldValue))) {
833                          r.setValue(newValue);
834                          replaced = true;
# Line 864 | Line 868 | public class CustomConcurrentHashMap<K,
868                          Object k = p.get();
869                          if (k == key ||
870                              (k != null &&
871 <                             p.getLocator() == hash &&
871 >                             p.getLocator() == hash &&
872                               keyEquivalence.equal((K)k, key))) {
873                              oldValue = (V)(p.getValue());
874                              if (pred == null)
875 <                                tab[i] = n;
875 >                                tab[i] = n;
876                              else
877                                  pred.setLinkage(n);
878                              seg.decrementCount();
# Line 911 | Line 915 | public class CustomConcurrentHashMap<K,
915                          Object k = p.get();
916                          if (k == key ||
917                              (k != null &&
918 <                             p.getLocator() == hash &&
918 >                             p.getLocator() == hash &&
919                               keyEquivalence.equal((K)k, key))) {
920                              V v = (V)(p.getValue());
921                              if (v == value ||
922 <                                (v != null &&
922 >                                (v != null &&
923                                   valueEquivalence.equal(v, value))) {
924                                  if (pred == null)
925 <                                    tab[i] = n;
925 >                                    tab[i] = n;
926                                  else
927                                      pred.setLinkage(n);
928                                  seg.decrementCount();
# Line 955 | Line 959 | public class CustomConcurrentHashMap<K,
959                      while (p != null) {
960                          Node n = p.getLinkage();
961                          if (p.get() != null && p.getValue() != null) {
962 +                            pred = p;
963 +                            p = n;
964 +                        }
965 +                        else {
966                              if (pred == null)
967 <                                tab[i] = n;
967 >                                tab[i] = n;
968                              else
969                                  pred.setLinkage(n);
970                              seg.decrementCount();
971                              p = n;
972                          }
965                        else {
966                            pred = p;
967                            p = n;
968                        }
973                      }
974                  }
975              } finally {
# Line 983 | Line 987 | public class CustomConcurrentHashMap<K,
987          final Segment[] segs = this.segments;
988          for (int i = 0; i < segs.length; ++i) {
989              Segment seg = segs[i];
990 <            if (seg != null &&
991 <                seg.getTableForTraversal() != null &&
990 >            if (seg != null &&
991 >                seg.getTableForTraversal() != null &&
992                  seg.count != 0)
993                  return false;
994          }
# Line 1006 | Line 1010 | public class CustomConcurrentHashMap<K,
1010              if (seg != null && seg.getTableForTraversal() != null)
1011                  sum += seg.count;
1012          }
1013 <        return sum >= Integer.MAX_VALUE? Integer.MAX_VALUE : (int)sum;
1013 >        return (sum >= Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) sum;
1014      }
1015  
1016      /**
# Line 1030 | Line 1034 | public class CustomConcurrentHashMap<K,
1034              Node[] tab;
1035              if (seg != null && (tab = seg.getTableForTraversal()) != null) {
1036                  for (int j = 0; j < tab.length; ++j) {
1037 <                    for (Node p = tab[j];
1038 <                         p != null;
1037 >                    for (Node p = tab[j];
1038 >                         p != null;
1039                           p = p.getLinkage()) {
1040                          V v = (V)(p.getValue());
1041                          if (v == value ||
# Line 1078 | Line 1082 | public class CustomConcurrentHashMap<K,
1082       * </pre>
1083       *
1084       * except that the action is performed atomically.  Some
1085 <     * attemmpted operations on this map by other threads may be
1085 >     * attempted operations on this map by other threads may be
1086       * blocked while computation is in progress. Because this function
1087       * is invoked within atomicity control, the computation should be
1088       * short and simple. The most common usage is to construct a new
# Line 1086 | Line 1090 | public class CustomConcurrentHashMap<K,
1090       *
1091       * @param key key with which the specified value is to be associated
1092       * @param mappingFunction the function to compute a value
1093 <     * @return the current (existing or computed) value associated with
1093 >     * @return the current (existing or computed) value associated with
1094       *         the specified key, or <tt>null</tt> if the computation
1095       *         returned <tt>null</tt>.
1096 <     * @throws NullPointerException if the specified key or mappingFunction
1096 >     * @throws NullPointerException if the specified key or mappingFunction
1097       *         is null,
1098       * @throws RuntimeException or Error if the mappingFunction does so,
1099       *         in which case the mapping is left unestablished.
# Line 1111 | Line 1115 | public class CustomConcurrentHashMap<K,
1115                      // Map is OK if function throws exception
1116                      v = mappingFunction.map(key);
1117                      if (v != null) {
1118 <                        if (r != null)
1118 >                        if (r != null)
1119                              r.setValue(v);
1120                          else {
1121                              Node[] tab = seg.getTableForAdd(this);
# Line 1144 | Line 1148 | public class CustomConcurrentHashMap<K,
1148       *   else
1149       *     return remove(key);
1150       * </pre>
1151 <     *
1152 <     * except that the action is performed atomically. Some attemmpted
1151 >     *
1152 >     * except that the action is performed atomically. Some attempted
1153       * operations on this map by other threads may be blocked while
1154       * computation is in progress.
1155       *
# Line 1154 | Line 1158 | public class CustomConcurrentHashMap<K,
1158       * <pre>
1159       * map.compute(word, new RemappingFunction&lt;String,Integer&gt;() {
1160       *   public Integer remap(String k, Integer v) {
1161 <     *     return v == null? 1 : v + 1;
1161 >     *     return (v == null) ? 1 : v + 1;
1162       *   }});
1163       * </pre>
1164       *
1165       * @param key key with which the specified value is to be associated
1166       * @param remappingFunction the function to compute a value
1167       * @return the updated value or
1168 <     *         <tt>null</tt> if the computation returned <tt>null</tt>
1169 <     * @throws NullPointerException if the specified key or remappingFunction
1168 >     *         <tt>null</tt> if the computation returned <tt>null</tt>
1169 >     * @throws NullPointerException if the specified key or remappingFunction
1170       *         is null,
1171       * @throws RuntimeException or Error if the remappingFunction does so,
1172       *         in which case the mapping is left in its previous state
# Line 1183 | Line 1187 | public class CustomConcurrentHashMap<K,
1187                  K k = (K)(p.get());
1188                  if (k == key ||
1189                      (k != null &&
1190 <                     p.getLocator() == hash &&
1190 >                     p.getLocator() == hash &&
1191                       keyEquivalence.equal(k, key))) {
1192                      value = (V)(p.getValue());
1193                      break;
# Line 1193 | Line 1197 | public class CustomConcurrentHashMap<K,
1197              }
1198              value = remappingFunction.remap(key, value);
1199              if (p != null) {
1200 <                if (value != null)
1200 >                if (value != null)
1201                      p.setValue(value);
1202                  else {
1203                      Node n = p.getLinkage();
1204                      if (pred == null)
1205 <                        tab[i] = n;
1205 >                        tab[i] = n;
1206                      else
1207                          pred.setLinkage(n);
1208                      seg.decrementCount();
1209                  }
1210              }
1211              else if (value != null) {
1212 <                Node r =
1212 >                Node r =
1213                      factory.newNode(hash, key, value, this, tab[i]);
1214                  // Fences.preStoreFence(r);
1215                  // tab[i] = r;
# Line 1254 | Line 1258 | public class CustomConcurrentHashMap<K,
1258                  else if (nextSegmentIndex >= 0) {
1259                      Segment seg = segments[nextSegmentIndex--];
1260                      Node[] t;
1261 <                    if (seg != null &&
1261 >                    if (seg != null &&
1262                          (t = seg.getTableForTraversal()) != null) {
1263                          currentTable = t;
1264                          nextTableIndex = t.length - 1;
# Line 1287 | Line 1291 | public class CustomConcurrentHashMap<K,
1291          final Map.Entry<K,V> nextEntry() {
1292              if (nextNode == null)
1293                  throw new NoSuchElementException();
1294 <            WriteThroughEntry e = new WriteThroughEntry((K)nextKey,
1294 >            WriteThroughEntry e = new WriteThroughEntry((K)nextKey,
1295                                                          (V)nextValue);
1296              advance();
1297              return e;
# Line 1330 | Line 1334 | public class CustomConcurrentHashMap<K,
1334          }
1335      }
1336  
1337 <    final class KeyIterator extends HashIterator
1337 >    final class KeyIterator extends HashIterator
1338          implements Iterator<K> {
1339 <        public K next() {
1340 <            return super.nextKey();
1339 >        public K next() {
1340 >            return super.nextKey();
1341          }
1342      }
1343  
# Line 1341 | Line 1345 | public class CustomConcurrentHashMap<K,
1345          return new KeyIterator();
1346      }
1347  
1348 <    final class ValueIterator extends HashIterator
1348 >    final class ValueIterator extends HashIterator
1349          implements Iterator<V> {
1350 <        public V next() {
1351 <            return super.nextValue();
1350 >        public V next() {
1351 >            return super.nextValue();
1352          }
1353      }
1354  
1355 <    final class EntryIterator extends HashIterator
1355 >    final class EntryIterator extends HashIterator
1356          implements Iterator<Map.Entry<K,V>> {
1357          public Map.Entry<K,V> next() {
1358              return super.nextEntry();
# Line 1403 | Line 1407 | public class CustomConcurrentHashMap<K,
1407                  return false;
1408              Map.Entry<?,?> e = (Map.Entry<?,?>)o;
1409              V v = CustomConcurrentHashMap.this.get(e.getKey());
1410 <            return v != null &&
1410 >            return v != null &&
1411                  valueEquivalence.equal(v, e.getValue());
1412          }
1413          public boolean remove(Object o) {
# Line 1501 | Line 1505 | public class CustomConcurrentHashMap<K,
1505      public boolean equals(Object o) {
1506          if (o == this)
1507              return true;
1508 <            
1508 >
1509          if (!(o instanceof Map))
1510              return false;
1511          Map<K,V> m = (Map<K,V>) o;
# Line 1554 | Line 1558 | public class CustomConcurrentHashMap<K,
1558       * for each key-value mapping, followed by a null pair.
1559       * The key-value mappings are emitted in no particular order.
1560       */
1561 <    private void writeObject(java.io.ObjectOutputStream s) throws IOException  {
1561 >    private void writeObject(java.io.ObjectOutputStream s) throws IOException {
1562          s.defaultWriteObject();
1563          for (Map.Entry<K,V> e : entrySet()) {
1564              s.writeObject(e.getKey());
# Line 1569 | Line 1573 | public class CustomConcurrentHashMap<K,
1573       * @param s the stream
1574       */
1575      private void readObject(java.io.ObjectInputStream s)
1576 <        throws IOException, ClassNotFoundException  {
1576 >        throws IOException, ClassNotFoundException {
1577          s.defaultReadObject();
1578          this.segments = (Segment[])(new Segment[NSEGMENTS]);
1579          for (;;) {
# Line 1602 | Line 1606 | public class CustomConcurrentHashMap<K,
1606           * that will be held in the set. If no estimate is known, zero
1607           * is an acceptable value.
1608           */
1609 <        public KeySet(Strength strength,
1609 >        public KeySet(Strength strength,
1610                        Equivalence<? super K> equivalence,
1611                        int expectedSize) {
1612              this.cchm = new CustomConcurrentHashMap<K,K>
1613 <                (strength.getName(), equivalence,
1613 >                (strength.getName(), equivalence,
1614                   SELF_STRING, equivalence, expectedSize);
1615          }
1616  
# Line 1614 | Line 1618 | public class CustomConcurrentHashMap<K,
1618           * Returns an element equivalent to the given element with
1619           * respect to this set's Equivalence, if such an element
1620           * exists, else adds and returns the given element.
1621 <         *
1621 >         *
1622           * @param e the element
1623           * @return e, or an element equivalent to e.
1624           */
1625          public K intern(K e) {
1626              K oldElement = cchm.doPut(e, e, true);
1627 <            return (oldElement != null) ? oldElement : e;
1627 >            return (oldElement != null) ? oldElement : e;
1628          }
1629 <        
1629 >
1630          /**
1631           * Returns <tt>true</tt> if this set contains an
1632           * element equivalent to the given element with respect
# Line 1633 | Line 1637 | public class CustomConcurrentHashMap<K,
1637          public boolean contains(Object o) {
1638              return cchm.containsKey(o);
1639          }
1640 <        
1640 >
1641          /**
1642           * Returns a <i>weakly consistent iterator</i> over the
1643           * elements in this set, that may reflect some, all or none of
# Line 1644 | Line 1648 | public class CustomConcurrentHashMap<K,
1648          public Iterator<K> iterator() {
1649              return cchm.keyIterator();
1650          }
1651 <        
1651 >
1652          /**
1653           * Adds the specified element to this set if there is not
1654           * already an element equivalent to the given element with
# Line 1686 | Line 1690 | public class CustomConcurrentHashMap<K,
1690          public int size() {
1691              return cchm.size();
1692          }
1693 <        
1693 >
1694          /**
1695           * Removes all of the elements from this set.
1696           */
# Line 1749 | Line 1753 | public class CustomConcurrentHashMap<K,
1753                      Reference<?> r = q.remove();
1754                      if (r instanceof Reclaimable)
1755                          ((Reclaimable)r).onReclamation();
1756 <                } catch (InterruptedException e) {
1757 <                    /* ignore */
1756 >                } catch (InterruptedException e) {
1757 >                    /* ignore */
1758                  }
1759              }
1760          }
# Line 1758 | Line 1762 | public class CustomConcurrentHashMap<K,
1762  
1763      // classes extending Weak/soft refs embedded in reclaimable nodes
1764  
1765 <    static class EmbeddedWeakReference extends WeakReference
1765 >    static class EmbeddedWeakReference extends WeakReference
1766          implements Reclaimable {
1767          final Reclaimable outer;
1768          EmbeddedWeakReference(Object x, Reclaimable outer) {
1769              super(x, getReclamationQueue());
1770              this.outer = outer;
1771          }
1772 <        public final void onReclamation() {
1772 >        public final void onReclamation() {
1773              clear();
1774 <            outer.onReclamation();
1774 >            outer.onReclamation();
1775          }
1776      }
1777  
1778 <    static class EmbeddedSoftReference extends SoftReference
1778 >    static class EmbeddedSoftReference extends SoftReference
1779          implements Reclaimable {
1780          final Reclaimable outer;
1781          EmbeddedSoftReference(Object x, Reclaimable outer) {
1782              super(x, getReclamationQueue());
1783              this.outer = outer;
1784          }
1785 <        public final void onReclamation() {
1785 >        public final void onReclamation() {
1786              clear();
1787 <            outer.onReclamation();
1787 >            outer.onReclamation();
1788          }
1789      }
1790  
# Line 1800 | Line 1804 | public class CustomConcurrentHashMap<K,
1804      }
1805  
1806  
1807 <    static abstract class StrongKeySelfValueNode
1807 >    static abstract class StrongKeySelfValueNode
1808          extends StrongKeyNode {
1809          StrongKeySelfValueNode(int locator, Object key) {
1810              super(locator, key);
# Line 1810 | Line 1814 | public class CustomConcurrentHashMap<K,
1814          public final void onReclamation() { }
1815      }
1816  
1817 <    static final class TerminalStrongKeySelfValueNode
1817 >    static final class TerminalStrongKeySelfValueNode
1818          extends StrongKeySelfValueNode {
1819          TerminalStrongKeySelfValueNode(int locator, Object key) {
1820              super(locator, key);
# Line 1819 | Line 1823 | public class CustomConcurrentHashMap<K,
1823          public final void setLinkage(Node r) { }
1824      }
1825  
1826 <    static final class LinkedStrongKeySelfValueNode
1826 >    static final class LinkedStrongKeySelfValueNode
1827          extends StrongKeySelfValueNode {
1828          volatile Node linkage;
1829 <        LinkedStrongKeySelfValueNode(int locator, Object key,
1829 >        LinkedStrongKeySelfValueNode(int locator, Object key,
1830                                       Node linkage) {
1831              super(locator, key);
1832              this.linkage = linkage;
# Line 1835 | Line 1839 | public class CustomConcurrentHashMap<K,
1839          implements NodeFactory, Serializable {
1840          private static final long serialVersionUID = 7249069346764182397L;
1841          public final Node newNode(int locator,
1842 <                                  Object key, Object value,
1842 >                                  Object key, Object value,
1843                                    CustomConcurrentHashMap cchm,
1844                                    Node linkage) {
1845              if (linkage == null)
# Line 1845 | Line 1849 | public class CustomConcurrentHashMap<K,
1849                  return new LinkedStrongKeySelfValueNode
1850                      (locator, key, linkage);
1851          }
1852 <    }        
1852 >    }
1853  
1854 <    static abstract class StrongKeyStrongValueNode
1854 >    static abstract class StrongKeyStrongValueNode
1855          extends StrongKeyNode {
1856          volatile Object value;
1857          StrongKeyStrongValueNode(int locator, Object key, Object value) {
# Line 1859 | Line 1863 | public class CustomConcurrentHashMap<K,
1863          public final void onReclamation() { }
1864      }
1865  
1866 <    static final class TerminalStrongKeyStrongValueNode
1866 >    static final class TerminalStrongKeyStrongValueNode
1867          extends StrongKeyStrongValueNode {
1868          TerminalStrongKeyStrongValueNode(int locator,
1869                                           Object key, Object value) {
# Line 1869 | Line 1873 | public class CustomConcurrentHashMap<K,
1873          public final void setLinkage(Node r) { }
1874      }
1875  
1876 <    static final class LinkedStrongKeyStrongValueNode
1876 >    static final class LinkedStrongKeyStrongValueNode
1877          extends StrongKeyStrongValueNode {
1878          volatile Node linkage;
1879          LinkedStrongKeyStrongValueNode(int locator,
1880 <                                       Object key, Object value,
1880 >                                       Object key, Object value,
1881                                         Node linkage) {
1882              super(locator, key, value);
1883              this.linkage = linkage;
# Line 1882 | Line 1886 | public class CustomConcurrentHashMap<K,
1886          public final void setLinkage(Node r) { linkage = r; }
1887      }
1888  
1889 <    static final class StrongKeyStrongValueNodeFactory
1889 >    static final class StrongKeyStrongValueNodeFactory
1890          implements NodeFactory, Serializable {
1891          private static final long serialVersionUID = 7249069346764182397L;
1892          public final Node newNode(int locator,
1893 <                                  Object key, Object value,
1893 >                                  Object key, Object value,
1894                                    CustomConcurrentHashMap cchm,
1895                                    Node linkage) {
1896              if (linkage == null)
# Line 1896 | Line 1900 | public class CustomConcurrentHashMap<K,
1900                  return new LinkedStrongKeyStrongValueNode
1901                      (locator, key, value, linkage);
1902          }
1903 <    }        
1903 >    }
1904  
1905      // ...
1906  
1907 <    static abstract class StrongKeyIntValueNode
1907 >    static abstract class StrongKeyIntValueNode
1908          extends StrongKeyNode {
1909          volatile int value;
1910          StrongKeyIntValueNode(int locator, Object key, Object value) {
# Line 1908 | Line 1912 | public class CustomConcurrentHashMap<K,
1912              this.value = ((Integer)value).intValue();
1913          }
1914          public final Object getValue() { return Integer.valueOf(value); }
1915 <        public final void setValue(Object value) {
1915 >        public final void setValue(Object value) {
1916              this.value = ((Integer)value).intValue();
1917          }
1918          public final void onReclamation() { }
1919      }
1920  
1921 <    static final class TerminalStrongKeyIntValueNode
1921 >    static final class TerminalStrongKeyIntValueNode
1922          extends StrongKeyIntValueNode {
1923          TerminalStrongKeyIntValueNode(int locator,
1924                                           Object key, Object value) {
# Line 1924 | Line 1928 | public class CustomConcurrentHashMap<K,
1928          public final void setLinkage(Node r) { }
1929      }
1930  
1931 <    static final class LinkedStrongKeyIntValueNode
1931 >    static final class LinkedStrongKeyIntValueNode
1932          extends StrongKeyIntValueNode {
1933          volatile Node linkage;
1934          LinkedStrongKeyIntValueNode(int locator,
1935 <                                       Object key, Object value,
1935 >                                       Object key, Object value,
1936                                         Node linkage) {
1937              super(locator, key, value);
1938              this.linkage = linkage;
# Line 1937 | Line 1941 | public class CustomConcurrentHashMap<K,
1941          public final void setLinkage(Node r) { linkage = r; }
1942      }
1943  
1944 <    static final class StrongKeyIntValueNodeFactory
1944 >    static final class StrongKeyIntValueNodeFactory
1945          implements NodeFactory, Serializable {
1946          private static final long serialVersionUID = 7249069346764182397L;
1947          public final Node newNode(int locator,
1948 <                                  Object key, Object value,
1948 >                                  Object key, Object value,
1949                                    CustomConcurrentHashMap cchm,
1950                                    Node linkage) {
1951              if (linkage == null)
# Line 1951 | Line 1955 | public class CustomConcurrentHashMap<K,
1955                  return new LinkedStrongKeyIntValueNode
1956                      (locator, key, value, linkage);
1957          }
1958 <    }        
1958 >    }
1959  
1960      // ...
1961  
1962 <    static abstract class StrongKeyWeakValueNode
1962 >    static abstract class StrongKeyWeakValueNode
1963          extends StrongKeyNode {
1964          volatile EmbeddedWeakReference valueRef;
1965          final CustomConcurrentHashMap cchm;
1966 <        StrongKeyWeakValueNode(int locator, Object key, Object value,
1966 >        StrongKeyWeakValueNode(int locator, Object key, Object value,
1967                                 CustomConcurrentHashMap cchm) {
1968              super(locator, key);
1969              this.cchm = cchm;
# Line 1971 | Line 1975 | public class CustomConcurrentHashMap<K,
1975          }
1976          public final Object getValue() {
1977              EmbeddedWeakReference vr = valueRef;
1978 <            return vr == null? null : vr.get();
1978 >            return (vr == null) ? null : vr.get();
1979          }
1980          public final void setValue(Object value) {
1981              if (value == null)
# Line 1981 | Line 1985 | public class CustomConcurrentHashMap<K,
1985          }
1986      }
1987  
1988 <    static final class TerminalStrongKeyWeakValueNode
1988 >    static final class TerminalStrongKeyWeakValueNode
1989          extends StrongKeyWeakValueNode {
1990          TerminalStrongKeyWeakValueNode(int locator,
1991 <                                       Object key, Object value,
1991 >                                       Object key, Object value,
1992                                         CustomConcurrentHashMap cchm) {
1993              super(locator, key, value, cchm);
1994          }
# Line 1992 | Line 1996 | public class CustomConcurrentHashMap<K,
1996          public final void setLinkage(Node r) { }
1997      }
1998  
1999 <    static final class LinkedStrongKeyWeakValueNode
1999 >    static final class LinkedStrongKeyWeakValueNode
2000          extends StrongKeyWeakValueNode {
2001          volatile Node linkage;
2002          LinkedStrongKeyWeakValueNode(int locator,
2003 <                                     Object key, Object value,
2003 >                                     Object key, Object value,
2004                                       CustomConcurrentHashMap cchm,
2005                                       Node linkage) {
2006              super(locator, key, value, cchm);
# Line 2006 | Line 2010 | public class CustomConcurrentHashMap<K,
2010          public final void setLinkage(Node r) { linkage = r; }
2011      }
2012  
2013 <    static final class StrongKeyWeakValueNodeFactory
2013 >    static final class StrongKeyWeakValueNodeFactory
2014          implements NodeFactory, Serializable {
2015          private static final long serialVersionUID = 7249069346764182397L;
2016 <        public final Node newNode(int locator,
2017 <                                  Object key, Object value,
2016 >        public final Node newNode(int locator,
2017 >                                  Object key, Object value,
2018                                    CustomConcurrentHashMap cchm,
2019                                    Node linkage) {
2020              if (linkage == null)
# Line 2020 | Line 2024 | public class CustomConcurrentHashMap<K,
2024                  return new LinkedStrongKeyWeakValueNode
2025                      (locator, key, value, cchm, linkage);
2026          }
2027 <    }        
2027 >    }
2028  
2029  
2030 <    static abstract class StrongKeySoftValueNode
2030 >    static abstract class StrongKeySoftValueNode
2031          extends StrongKeyNode {
2032          volatile EmbeddedSoftReference valueRef;
2033          final CustomConcurrentHashMap cchm;
2034 <        StrongKeySoftValueNode(int locator, Object key, Object value,
2034 >        StrongKeySoftValueNode(int locator, Object key, Object value,
2035                                 CustomConcurrentHashMap cchm) {
2036              super(locator, key);
2037              this.cchm = cchm;
# Line 2039 | Line 2043 | public class CustomConcurrentHashMap<K,
2043          }
2044          public final Object getValue() {
2045              EmbeddedSoftReference vr = valueRef;
2046 <            return vr == null? null : vr.get();
2046 >            return (vr == null) ? null : vr.get();
2047          }
2048          public final void setValue(Object value) {
2049              if (value == null)
# Line 2049 | Line 2053 | public class CustomConcurrentHashMap<K,
2053          }
2054      }
2055  
2056 <    static final class TerminalStrongKeySoftValueNode
2056 >    static final class TerminalStrongKeySoftValueNode
2057          extends StrongKeySoftValueNode {
2058          TerminalStrongKeySoftValueNode(int locator,
2059 <                                       Object key, Object value,
2059 >                                       Object key, Object value,
2060                                         CustomConcurrentHashMap cchm) {
2061              super(locator, key, value, cchm);
2062          }
# Line 2060 | Line 2064 | public class CustomConcurrentHashMap<K,
2064          public final void setLinkage(Node r) { }
2065      }
2066  
2067 <    static final class LinkedStrongKeySoftValueNode
2067 >    static final class LinkedStrongKeySoftValueNode
2068          extends StrongKeySoftValueNode {
2069          volatile Node linkage;
2070          LinkedStrongKeySoftValueNode(int locator,
2071 <                                     Object key, Object value,
2071 >                                     Object key, Object value,
2072                                       CustomConcurrentHashMap cchm,
2073                                       Node linkage) {
2074              super(locator, key, value, cchm);
# Line 2074 | Line 2078 | public class CustomConcurrentHashMap<K,
2078          public final void setLinkage(Node r) { linkage = r; }
2079      }
2080  
2081 <    static final class StrongKeySoftValueNodeFactory
2081 >    static final class StrongKeySoftValueNodeFactory
2082          implements NodeFactory, Serializable {
2083          private static final long serialVersionUID = 7249069346764182397L;
2084 <        public final Node newNode(int locator,
2085 <                                  Object key, Object value,
2084 >        public final Node newNode(int locator,
2085 >                                  Object key, Object value,
2086                                    CustomConcurrentHashMap cchm,
2087                                    Node linkage) {
2088              if (linkage == null)
# Line 2088 | Line 2092 | public class CustomConcurrentHashMap<K,
2092                  return new LinkedStrongKeySoftValueNode
2093                      (locator, key, value, cchm, linkage);
2094          }
2095 <    }        
2095 >    }
2096  
2097      // Weak keys
2098  
# Line 2097 | Line 2101 | public class CustomConcurrentHashMap<K,
2101          final int locator;
2102          final CustomConcurrentHashMap cchm;
2103          WeakKeyNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2104 <            super(key);
2104 >            super(key, getReclamationQueue());
2105              this.locator = locator;
2106              this.cchm = cchm;
2107          }
2108          public final int getLocator() { return locator; }
2109 <        public final void onReclamation() {
2109 >        public final void onReclamation() {
2110              clear();
2111              cchm.removeIfReclaimed(this);
2112          }
2113      }
2114  
2115 <    static abstract class WeakKeySelfValueNode
2115 >    static abstract class WeakKeySelfValueNode
2116          extends WeakKeyNode {
2117          WeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2118              super(locator, key, cchm);
# Line 2117 | Line 2121 | public class CustomConcurrentHashMap<K,
2121          public final void setValue(Object value) { }
2122      }
2123  
2124 <    static final class TerminalWeakKeySelfValueNode
2124 >    static final class TerminalWeakKeySelfValueNode
2125          extends WeakKeySelfValueNode {
2126 <        TerminalWeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2126 >        TerminalWeakKeySelfValueNode(int locator, Object key,
2127 >                                     CustomConcurrentHashMap cchm) {
2128              super(locator, key, cchm);
2129          }
2130          public final Node getLinkage() { return null; }
2131          public final void setLinkage(Node r) { }
2132      }
2133  
2134 <    static final class LinkedWeakKeySelfValueNode
2134 >    static final class LinkedWeakKeySelfValueNode
2135          extends WeakKeySelfValueNode {
2136          volatile Node linkage;
2137          LinkedWeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm,
# Line 2142 | Line 2147 | public class CustomConcurrentHashMap<K,
2147          implements NodeFactory, Serializable {
2148          private static final long serialVersionUID = 7249069346764182397L;
2149          public final Node newNode(int locator,
2150 <                                  Object key, Object value,
2150 >                                  Object key, Object value,
2151                                    CustomConcurrentHashMap cchm,
2152                                    Node linkage) {
2153              if (linkage == null)
# Line 2152 | Line 2157 | public class CustomConcurrentHashMap<K,
2157                  return new LinkedWeakKeySelfValueNode
2158                      (locator, key, cchm, linkage);
2159          }
2160 <    }        
2160 >    }
2161  
2162  
2163 <    static abstract class WeakKeyStrongValueNode
2163 >    static abstract class WeakKeyStrongValueNode
2164          extends WeakKeyNode {
2165          volatile Object value;
2166          WeakKeyStrongValueNode(int locator, Object key, Object value, CustomConcurrentHashMap cchm) {
# Line 2166 | Line 2171 | public class CustomConcurrentHashMap<K,
2171          public final void setValue(Object value) { this.value = value; }
2172      }
2173  
2174 <    static final class TerminalWeakKeyStrongValueNode
2174 >    static final class TerminalWeakKeyStrongValueNode
2175          extends WeakKeyStrongValueNode {
2176          TerminalWeakKeyStrongValueNode(int locator,
2177                                         Object key, Object value, CustomConcurrentHashMap cchm) {
# Line 2176 | Line 2181 | public class CustomConcurrentHashMap<K,
2181          public final void setLinkage(Node r) { }
2182      }
2183  
2184 <    static final class LinkedWeakKeyStrongValueNode
2184 >    static final class LinkedWeakKeyStrongValueNode
2185          extends WeakKeyStrongValueNode {
2186          volatile Node linkage;
2187          LinkedWeakKeyStrongValueNode(int locator,
# Line 2189 | Line 2194 | public class CustomConcurrentHashMap<K,
2194          public final void setLinkage(Node r) { linkage = r; }
2195      }
2196  
2197 <    static final class WeakKeyStrongValueNodeFactory
2197 >    static final class WeakKeyStrongValueNodeFactory
2198          implements NodeFactory, Serializable {
2199          private static final long serialVersionUID = 7249069346764182397L;
2200          public final Node newNode(int locator,
2201 <                                  Object key, Object value,
2201 >                                  Object key, Object value,
2202                                    CustomConcurrentHashMap cchm,
2203                                    Node linkage) {
2204              if (linkage == null)
# Line 2203 | Line 2208 | public class CustomConcurrentHashMap<K,
2208                  return new LinkedWeakKeyStrongValueNode
2209                      (locator, key, value, cchm, linkage);
2210          }
2211 <    }        
2211 >    }
2212  
2213 <    static abstract class WeakKeyIntValueNode
2213 >    static abstract class WeakKeyIntValueNode
2214          extends WeakKeyNode {
2215          volatile int value;
2216          WeakKeyIntValueNode(int locator, Object key, Object value,
# Line 2214 | Line 2219 | public class CustomConcurrentHashMap<K,
2219              this.value = ((Integer)value).intValue();
2220          }
2221          public final Object getValue() { return Integer.valueOf(value); }
2222 <        public final void setValue(Object value) {
2222 >        public final void setValue(Object value) {
2223              this.value = ((Integer)value).intValue();
2224          }
2225      }
2226  
2227 <    static final class TerminalWeakKeyIntValueNode
2227 >    static final class TerminalWeakKeyIntValueNode
2228          extends WeakKeyIntValueNode {
2229          TerminalWeakKeyIntValueNode(int locator,
2230                                      Object key, Object value,
# Line 2230 | Line 2235 | public class CustomConcurrentHashMap<K,
2235          public final void setLinkage(Node r) { }
2236      }
2237  
2238 <    static final class LinkedWeakKeyIntValueNode
2238 >    static final class LinkedWeakKeyIntValueNode
2239          extends WeakKeyIntValueNode {
2240          volatile Node linkage;
2241          LinkedWeakKeyIntValueNode(int locator,
2242 <                                  Object key, Object value,
2242 >                                  Object key, Object value,
2243                                    CustomConcurrentHashMap cchm,
2244                                    Node linkage) {
2245              super(locator, key, value, cchm);
# Line 2244 | Line 2249 | public class CustomConcurrentHashMap<K,
2249          public final void setLinkage(Node r) { linkage = r; }
2250      }
2251  
2252 <    static final class WeakKeyIntValueNodeFactory
2252 >    static final class WeakKeyIntValueNodeFactory
2253          implements NodeFactory, Serializable {
2254          private static final long serialVersionUID = 7249069346764182397L;
2255          public final Node newNode(int locator,
2256 <                                  Object key, Object value,
2256 >                                  Object key, Object value,
2257                                    CustomConcurrentHashMap cchm,
2258                                    Node linkage) {
2259              if (linkage == null)
# Line 2258 | Line 2263 | public class CustomConcurrentHashMap<K,
2263                  return new LinkedWeakKeyIntValueNode
2264                      (locator, key, value, cchm, linkage);
2265          }
2266 <    }        
2266 >    }
2267  
2268 <    static abstract class WeakKeyWeakValueNode
2268 >    static abstract class WeakKeyWeakValueNode
2269          extends WeakKeyNode {
2270          volatile EmbeddedWeakReference valueRef;
2271 <        WeakKeyWeakValueNode(int locator, Object key, Object value,
2271 >        WeakKeyWeakValueNode(int locator, Object key, Object value,
2272                               CustomConcurrentHashMap cchm) {
2273              super(locator, key, cchm);
2274              if (value != null)
# Line 2271 | Line 2276 | public class CustomConcurrentHashMap<K,
2276          }
2277          public final Object getValue() {
2278              EmbeddedWeakReference vr = valueRef;
2279 <            return vr == null? null : vr.get();
2279 >            return (vr == null) ? null : vr.get();
2280          }
2281          public final void setValue(Object value) {
2282              if (value == null)
# Line 2281 | Line 2286 | public class CustomConcurrentHashMap<K,
2286          }
2287      }
2288  
2289 <    static final class TerminalWeakKeyWeakValueNode
2289 >    static final class TerminalWeakKeyWeakValueNode
2290          extends WeakKeyWeakValueNode {
2291          TerminalWeakKeyWeakValueNode(int locator,
2292 <                                     Object key, Object value,
2292 >                                     Object key, Object value,
2293                                       CustomConcurrentHashMap cchm) {
2294              super(locator, key, value, cchm);
2295          }
# Line 2292 | Line 2297 | public class CustomConcurrentHashMap<K,
2297          public final void setLinkage(Node r) { }
2298      }
2299  
2300 <    static final class LinkedWeakKeyWeakValueNode
2300 >    static final class LinkedWeakKeyWeakValueNode
2301          extends WeakKeyWeakValueNode {
2302          volatile Node linkage;
2303          LinkedWeakKeyWeakValueNode(int locator,
2304 <                                   Object key, Object value,
2304 >                                   Object key, Object value,
2305                                     CustomConcurrentHashMap cchm,
2306                                     Node linkage) {
2307              super(locator, key, value, cchm);
# Line 2306 | Line 2311 | public class CustomConcurrentHashMap<K,
2311          public final void setLinkage(Node r) { linkage = r; }
2312      }
2313  
2314 <    static final class WeakKeyWeakValueNodeFactory
2314 >    static final class WeakKeyWeakValueNodeFactory
2315          implements NodeFactory, Serializable {
2316          private static final long serialVersionUID = 7249069346764182397L;
2317 <        public final Node newNode(int locator,
2318 <                                  Object key, Object value,
2317 >        public final Node newNode(int locator,
2318 >                                  Object key, Object value,
2319                                    CustomConcurrentHashMap cchm,
2320                                    Node linkage) {
2321              if (linkage == null)
# Line 2320 | Line 2325 | public class CustomConcurrentHashMap<K,
2325                  return new LinkedWeakKeyWeakValueNode
2326                      (locator, key, value, cchm, linkage);
2327          }
2328 <    }        
2328 >    }
2329  
2330  
2331 <    static abstract class WeakKeySoftValueNode
2331 >    static abstract class WeakKeySoftValueNode
2332          extends WeakKeyNode {
2333          volatile EmbeddedSoftReference valueRef;
2334 <        WeakKeySoftValueNode(int locator, Object key, Object value,
2334 >        WeakKeySoftValueNode(int locator, Object key, Object value,
2335                               CustomConcurrentHashMap cchm) {
2336              super(locator, key, cchm);
2337              if (value != null)
# Line 2334 | Line 2339 | public class CustomConcurrentHashMap<K,
2339          }
2340          public final Object getValue() {
2341              EmbeddedSoftReference vr = valueRef;
2342 <            return vr == null? null : vr.get();
2342 >            return (vr == null) ? null : vr.get();
2343          }
2344          public final void setValue(Object value) {
2345              if (value == null)
# Line 2344 | Line 2349 | public class CustomConcurrentHashMap<K,
2349          }
2350      }
2351  
2352 <    static final class TerminalWeakKeySoftValueNode
2352 >    static final class TerminalWeakKeySoftValueNode
2353          extends WeakKeySoftValueNode {
2354          TerminalWeakKeySoftValueNode(int locator,
2355 <                                     Object key, Object value,
2355 >                                     Object key, Object value,
2356                                       CustomConcurrentHashMap cchm) {
2357              super(locator, key, value, cchm);
2358          }
# Line 2355 | Line 2360 | public class CustomConcurrentHashMap<K,
2360          public final void setLinkage(Node r) { }
2361      }
2362  
2363 <    static final class LinkedWeakKeySoftValueNode
2363 >    static final class LinkedWeakKeySoftValueNode
2364          extends WeakKeySoftValueNode {
2365          volatile Node linkage;
2366          LinkedWeakKeySoftValueNode(int locator,
2367 <                                   Object key, Object value,
2367 >                                   Object key, Object value,
2368                                     CustomConcurrentHashMap cchm,
2369                                     Node linkage) {
2370              super(locator, key, value, cchm);
# Line 2369 | Line 2374 | public class CustomConcurrentHashMap<K,
2374          public final void setLinkage(Node r) { linkage = r; }
2375      }
2376  
2377 <    static final class WeakKeySoftValueNodeFactory
2377 >    static final class WeakKeySoftValueNodeFactory
2378          implements NodeFactory, Serializable {
2379          private static final long serialVersionUID = 7249069346764182397L;
2380 <        public final Node newNode(int locator,
2381 <                                  Object key, Object value,
2380 >        public final Node newNode(int locator,
2381 >                                  Object key, Object value,
2382                                    CustomConcurrentHashMap cchm,
2383                                    Node linkage) {
2384              if (linkage == null)
# Line 2383 | Line 2388 | public class CustomConcurrentHashMap<K,
2388                  return new LinkedWeakKeySoftValueNode
2389                      (locator, key, value, cchm, linkage);
2390          }
2391 <    }        
2391 >    }
2392  
2393      // Soft keys
2394  
# Line 2392 | Line 2397 | public class CustomConcurrentHashMap<K,
2397          final int locator;
2398          final CustomConcurrentHashMap cchm;
2399          SoftKeyNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2400 <            super(key);
2400 >            super(key, getReclamationQueue());
2401              this.locator = locator;
2402              this.cchm = cchm;
2403          }
2404          public final int getLocator() { return locator; }
2405 <        public final void onReclamation() {
2405 >        public final void onReclamation() {
2406              clear();
2407              cchm.removeIfReclaimed(this);
2408          }
2409      }
2410  
2411 <    static abstract class SoftKeySelfValueNode
2411 >    static abstract class SoftKeySelfValueNode
2412          extends SoftKeyNode {
2413          SoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2414              super(locator, key, cchm);
# Line 2412 | Line 2417 | public class CustomConcurrentHashMap<K,
2417          public final void setValue(Object value) { }
2418      }
2419  
2420 <    static final class TerminalSoftKeySelfValueNode
2420 >    static final class TerminalSoftKeySelfValueNode
2421          extends SoftKeySelfValueNode {
2422          TerminalSoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2423              super(locator, key, cchm);
# Line 2421 | Line 2426 | public class CustomConcurrentHashMap<K,
2426          public final void setLinkage(Node r) { }
2427      }
2428  
2429 <    static final class LinkedSoftKeySelfValueNode
2429 >    static final class LinkedSoftKeySelfValueNode
2430          extends SoftKeySelfValueNode {
2431          volatile Node linkage;
2432          LinkedSoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm,
# Line 2437 | Line 2442 | public class CustomConcurrentHashMap<K,
2442          implements NodeFactory, Serializable {
2443          private static final long serialVersionUID = 7249069346764182397L;
2444          public final Node newNode(int locator,
2445 <                                  Object key, Object value,
2445 >                                  Object key, Object value,
2446                                    CustomConcurrentHashMap cchm,
2447                                    Node linkage) {
2448              if (linkage == null)
# Line 2447 | Line 2452 | public class CustomConcurrentHashMap<K,
2452                  return new LinkedSoftKeySelfValueNode
2453                      (locator, key, cchm, linkage);
2454          }
2455 <    }        
2455 >    }
2456  
2457  
2458 <    static abstract class SoftKeyStrongValueNode
2458 >    static abstract class SoftKeyStrongValueNode
2459          extends SoftKeyNode {
2460          volatile Object value;
2461          SoftKeyStrongValueNode(int locator, Object key, Object value, CustomConcurrentHashMap cchm) {
# Line 2461 | Line 2466 | public class CustomConcurrentHashMap<K,
2466          public final void setValue(Object value) { this.value = value; }
2467      }
2468  
2469 <    static final class TerminalSoftKeyStrongValueNode
2469 >    static final class TerminalSoftKeyStrongValueNode
2470          extends SoftKeyStrongValueNode {
2471          TerminalSoftKeyStrongValueNode(int locator,
2472                                         Object key, Object value, CustomConcurrentHashMap cchm) {
# Line 2471 | Line 2476 | public class CustomConcurrentHashMap<K,
2476          public final void setLinkage(Node r) { }
2477      }
2478  
2479 <    static final class LinkedSoftKeyStrongValueNode
2479 >    static final class LinkedSoftKeyStrongValueNode
2480          extends SoftKeyStrongValueNode {
2481          volatile Node linkage;
2482          LinkedSoftKeyStrongValueNode(int locator,
# Line 2484 | Line 2489 | public class CustomConcurrentHashMap<K,
2489          public final void setLinkage(Node r) { linkage = r; }
2490      }
2491  
2492 <    static final class SoftKeyStrongValueNodeFactory
2492 >    static final class SoftKeyStrongValueNodeFactory
2493          implements NodeFactory, Serializable {
2494          private static final long serialVersionUID = 7249069346764182397L;
2495          public final Node newNode(int locator,
2496 <                                  Object key, Object value,
2496 >                                  Object key, Object value,
2497                                    CustomConcurrentHashMap cchm,
2498                                    Node linkage) {
2499              if (linkage == null)
# Line 2498 | Line 2503 | public class CustomConcurrentHashMap<K,
2503                  return new LinkedSoftKeyStrongValueNode
2504                      (locator, key, value, cchm, linkage);
2505          }
2506 <    }        
2506 >    }
2507  
2508 <    static abstract class SoftKeyIntValueNode
2508 >    static abstract class SoftKeyIntValueNode
2509          extends SoftKeyNode {
2510          volatile int value;
2511          SoftKeyIntValueNode(int locator, Object key, Object value,
# Line 2509 | Line 2514 | public class CustomConcurrentHashMap<K,
2514              this.value = ((Integer)value).intValue();
2515          }
2516          public final Object getValue() { return Integer.valueOf(value); }
2517 <        public final void setValue(Object value) {
2517 >        public final void setValue(Object value) {
2518              this.value = ((Integer)value).intValue();
2519          }
2520      }
2521  
2522 <    static final class TerminalSoftKeyIntValueNode
2522 >    static final class TerminalSoftKeyIntValueNode
2523          extends SoftKeyIntValueNode {
2524          TerminalSoftKeyIntValueNode(int locator,
2525                                      Object key, Object value,
# Line 2525 | Line 2530 | public class CustomConcurrentHashMap<K,
2530          public final void setLinkage(Node r) { }
2531      }
2532  
2533 <    static final class LinkedSoftKeyIntValueNode
2533 >    static final class LinkedSoftKeyIntValueNode
2534          extends SoftKeyIntValueNode {
2535          volatile Node linkage;
2536          LinkedSoftKeyIntValueNode(int locator,
2537 <                                  Object key, Object value,
2537 >                                  Object key, Object value,
2538                                    CustomConcurrentHashMap cchm,
2539                                    Node linkage) {
2540              super(locator, key, value, cchm);
# Line 2539 | Line 2544 | public class CustomConcurrentHashMap<K,
2544          public final void setLinkage(Node r) { linkage = r; }
2545      }
2546  
2547 <    static final class SoftKeyIntValueNodeFactory
2547 >    static final class SoftKeyIntValueNodeFactory
2548          implements NodeFactory, Serializable {
2549          private static final long serialVersionUID = 7249069346764182397L;
2550          public final Node newNode(int locator,
2551 <                                  Object key, Object value,
2551 >                                  Object key, Object value,
2552                                    CustomConcurrentHashMap cchm,
2553                                    Node linkage) {
2554              if (linkage == null)
# Line 2553 | Line 2558 | public class CustomConcurrentHashMap<K,
2558                  return new LinkedSoftKeyIntValueNode
2559                      (locator, key, value, cchm, linkage);
2560          }
2561 <    }        
2561 >    }
2562  
2563 <    static abstract class SoftKeyWeakValueNode
2563 >    static abstract class SoftKeyWeakValueNode
2564          extends SoftKeyNode {
2565          volatile EmbeddedWeakReference valueRef;
2566 <        SoftKeyWeakValueNode(int locator, Object key, Object value,
2566 >        SoftKeyWeakValueNode(int locator, Object key, Object value,
2567                               CustomConcurrentHashMap cchm) {
2568              super(locator, key, cchm);
2569              if (value != null)
# Line 2566 | Line 2571 | public class CustomConcurrentHashMap<K,
2571          }
2572          public final Object getValue() {
2573              EmbeddedWeakReference vr = valueRef;
2574 <            return vr == null? null : vr.get();
2574 >            return (vr == null) ? null : vr.get();
2575          }
2576          public final void setValue(Object value) {
2577              if (value == null)
# Line 2576 | Line 2581 | public class CustomConcurrentHashMap<K,
2581          }
2582      }
2583  
2584 <    static final class TerminalSoftKeyWeakValueNode
2584 >    static final class TerminalSoftKeyWeakValueNode
2585          extends SoftKeyWeakValueNode {
2586          TerminalSoftKeyWeakValueNode(int locator,
2587 <                                     Object key, Object value,
2587 >                                     Object key, Object value,
2588                                       CustomConcurrentHashMap cchm) {
2589              super(locator, key, value, cchm);
2590          }
# Line 2587 | Line 2592 | public class CustomConcurrentHashMap<K,
2592          public final void setLinkage(Node r) { }
2593      }
2594  
2595 <    static final class LinkedSoftKeyWeakValueNode
2595 >    static final class LinkedSoftKeyWeakValueNode
2596          extends SoftKeyWeakValueNode {
2597          volatile Node linkage;
2598          LinkedSoftKeyWeakValueNode(int locator,
2599 <                                   Object key, Object value,
2599 >                                   Object key, Object value,
2600                                     CustomConcurrentHashMap cchm,
2601                                     Node linkage) {
2602              super(locator, key, value, cchm);
# Line 2601 | Line 2606 | public class CustomConcurrentHashMap<K,
2606          public final void setLinkage(Node r) { linkage = r; }
2607      }
2608  
2609 <    static final class SoftKeyWeakValueNodeFactory
2609 >    static final class SoftKeyWeakValueNodeFactory
2610          implements NodeFactory, Serializable {
2611          private static final long serialVersionUID = 7249069346764182397L;
2612 <        public final Node newNode(int locator,
2613 <                                  Object key, Object value,
2612 >        public final Node newNode(int locator,
2613 >                                  Object key, Object value,
2614                                    CustomConcurrentHashMap cchm,
2615                                    Node linkage) {
2616              if (linkage == null)
# Line 2615 | Line 2620 | public class CustomConcurrentHashMap<K,
2620                  return new LinkedSoftKeyWeakValueNode
2621                      (locator, key, value, cchm, linkage);
2622          }
2623 <    }        
2623 >    }
2624  
2625  
2626 <    static abstract class SoftKeySoftValueNode
2626 >    static abstract class SoftKeySoftValueNode
2627          extends SoftKeyNode {
2628          volatile EmbeddedSoftReference valueRef;
2629 <        SoftKeySoftValueNode(int locator, Object key, Object value,
2629 >        SoftKeySoftValueNode(int locator, Object key, Object value,
2630                               CustomConcurrentHashMap cchm) {
2631              super(locator, key, cchm);
2632              if (value != null)
# Line 2629 | Line 2634 | public class CustomConcurrentHashMap<K,
2634          }
2635          public final Object getValue() {
2636              EmbeddedSoftReference vr = valueRef;
2637 <            return vr == null? null : vr.get();
2637 >            return (vr == null) ? null : vr.get();
2638          }
2639          public final void setValue(Object value) {
2640              if (value == null)
# Line 2639 | Line 2644 | public class CustomConcurrentHashMap<K,
2644          }
2645      }
2646  
2647 <    static final class TerminalSoftKeySoftValueNode
2647 >    static final class TerminalSoftKeySoftValueNode
2648          extends SoftKeySoftValueNode {
2649          TerminalSoftKeySoftValueNode(int locator,
2650 <                                     Object key, Object value,
2650 >                                     Object key, Object value,
2651                                       CustomConcurrentHashMap cchm) {
2652              super(locator, key, value, cchm);
2653          }
# Line 2650 | Line 2655 | public class CustomConcurrentHashMap<K,
2655          public final void setLinkage(Node r) { }
2656      }
2657  
2658 <    static final class LinkedSoftKeySoftValueNode
2658 >    static final class LinkedSoftKeySoftValueNode
2659          extends SoftKeySoftValueNode {
2660          volatile Node linkage;
2661          LinkedSoftKeySoftValueNode(int locator,
2662 <                                   Object key, Object value,
2662 >                                   Object key, Object value,
2663                                     CustomConcurrentHashMap cchm,
2664                                     Node linkage) {
2665              super(locator, key, value, cchm);
# Line 2664 | Line 2669 | public class CustomConcurrentHashMap<K,
2669          public final void setLinkage(Node r) { linkage = r; }
2670      }
2671  
2672 <    static final class SoftKeySoftValueNodeFactory
2672 >    static final class SoftKeySoftValueNodeFactory
2673          implements NodeFactory, Serializable {
2674          private static final long serialVersionUID = 7249069346764182397L;
2675 <        public final Node newNode(int locator,
2676 <                                  Object key, Object value,
2675 >        public final Node newNode(int locator,
2676 >                                  Object key, Object value,
2677                                    CustomConcurrentHashMap cchm,
2678                                    Node linkage) {
2679              if (linkage == null)
# Line 2678 | Line 2683 | public class CustomConcurrentHashMap<K,
2683                  return new LinkedSoftKeySoftValueNode
2684                      (locator, key, value, cchm, linkage);
2685          }
2686 <    }        
2686 >    }
2687  
2688      static abstract class IntKeyNode implements Node {
2689          final int key;
# Line 2690 | Line 2695 | public class CustomConcurrentHashMap<K,
2695      }
2696  
2697  
2698 <    static abstract class IntKeySelfValueNode
2698 >    static abstract class IntKeySelfValueNode
2699          extends IntKeyNode {
2700          IntKeySelfValueNode(int locator, Object key) {
2701              super(locator, key);
# Line 2700 | Line 2705 | public class CustomConcurrentHashMap<K,
2705          public final void onReclamation() { }
2706      }
2707  
2708 <    static final class TerminalIntKeySelfValueNode
2708 >    static final class TerminalIntKeySelfValueNode
2709          extends IntKeySelfValueNode {
2710          TerminalIntKeySelfValueNode(int locator, Object key) {
2711              super(locator, key);
# Line 2709 | Line 2714 | public class CustomConcurrentHashMap<K,
2714          public final void setLinkage(Node r) { }
2715      }
2716  
2717 <    static final class LinkedIntKeySelfValueNode
2717 >    static final class LinkedIntKeySelfValueNode
2718          extends IntKeySelfValueNode {
2719          volatile Node linkage;
2720 <        LinkedIntKeySelfValueNode(int locator, Object key,
2720 >        LinkedIntKeySelfValueNode(int locator, Object key,
2721                                       Node linkage) {
2722              super(locator, key);
2723              this.linkage = linkage;
# Line 2725 | Line 2730 | public class CustomConcurrentHashMap<K,
2730          implements NodeFactory, Serializable {
2731          private static final long serialVersionUID = 7249069346764182397L;
2732          public final Node newNode(int locator,
2733 <                                  Object key, Object value,
2733 >                                  Object key, Object value,
2734                                    CustomConcurrentHashMap cchm,
2735                                    Node linkage) {
2736              if (linkage == null)
# Line 2735 | Line 2740 | public class CustomConcurrentHashMap<K,
2740                  return new LinkedIntKeySelfValueNode
2741                      (locator, key, linkage);
2742          }
2743 <    }        
2743 >    }
2744  
2745 <    static abstract class IntKeyStrongValueNode
2745 >    static abstract class IntKeyStrongValueNode
2746          extends IntKeyNode {
2747          volatile Object value;
2748          IntKeyStrongValueNode(int locator, Object key, Object value) {
# Line 2749 | Line 2754 | public class CustomConcurrentHashMap<K,
2754          public final void onReclamation() { }
2755      }
2756  
2757 <    static final class TerminalIntKeyStrongValueNode
2757 >    static final class TerminalIntKeyStrongValueNode
2758          extends IntKeyStrongValueNode {
2759          TerminalIntKeyStrongValueNode(int locator,
2760                                           Object key, Object value) {
# Line 2759 | Line 2764 | public class CustomConcurrentHashMap<K,
2764          public final void setLinkage(Node r) { }
2765      }
2766  
2767 <    static final class LinkedIntKeyStrongValueNode
2767 >    static final class LinkedIntKeyStrongValueNode
2768          extends IntKeyStrongValueNode {
2769          volatile Node linkage;
2770          LinkedIntKeyStrongValueNode(int locator,
2771 <                                       Object key, Object value,
2771 >                                       Object key, Object value,
2772                                         Node linkage) {
2773              super(locator, key, value);
2774              this.linkage = linkage;
# Line 2772 | Line 2777 | public class CustomConcurrentHashMap<K,
2777          public final void setLinkage(Node r) { linkage = r; }
2778      }
2779  
2780 <    static final class IntKeyStrongValueNodeFactory
2780 >    static final class IntKeyStrongValueNodeFactory
2781          implements NodeFactory, Serializable {
2782          private static final long serialVersionUID = 7249069346764182397L;
2783          public final Node newNode(int locator,
2784 <                                  Object key, Object value,
2784 >                                  Object key, Object value,
2785                                    CustomConcurrentHashMap cchm,
2786                                    Node linkage) {
2787              if (linkage == null)
# Line 2786 | Line 2791 | public class CustomConcurrentHashMap<K,
2791                  return new LinkedIntKeyStrongValueNode
2792                      (locator, key, value, linkage);
2793          }
2794 <    }        
2794 >    }
2795  
2796 <    static abstract class IntKeyIntValueNode
2796 >    static abstract class IntKeyIntValueNode
2797          extends IntKeyNode {
2798          volatile int value;
2799          IntKeyIntValueNode(int locator, Object key, Object value) {
# Line 2796 | Line 2801 | public class CustomConcurrentHashMap<K,
2801              this.value = ((Integer)value).intValue();
2802          }
2803          public final Object getValue() { return Integer.valueOf(value); }
2804 <        public final void setValue(Object value) {
2804 >        public final void setValue(Object value) {
2805              this.value = ((Integer)value).intValue();
2806          }
2807          public final void onReclamation() { }
2808      }
2809  
2810 <    static final class TerminalIntKeyIntValueNode
2810 >    static final class TerminalIntKeyIntValueNode
2811          extends IntKeyIntValueNode {
2812          TerminalIntKeyIntValueNode(int locator,
2813                                           Object key, Object value) {
# Line 2812 | Line 2817 | public class CustomConcurrentHashMap<K,
2817          public final void setLinkage(Node r) { }
2818      }
2819  
2820 <    static final class LinkedIntKeyIntValueNode
2820 >    static final class LinkedIntKeyIntValueNode
2821          extends IntKeyIntValueNode {
2822          volatile Node linkage;
2823          LinkedIntKeyIntValueNode(int locator,
2824 <                                       Object key, Object value,
2824 >                                       Object key, Object value,
2825                                         Node linkage) {
2826              super(locator, key, value);
2827              this.linkage = linkage;
# Line 2825 | Line 2830 | public class CustomConcurrentHashMap<K,
2830          public final void setLinkage(Node r) { linkage = r; }
2831      }
2832  
2833 <    static final class IntKeyIntValueNodeFactory
2833 >    static final class IntKeyIntValueNodeFactory
2834          implements NodeFactory, Serializable {
2835          private static final long serialVersionUID = 7249069346764182397L;
2836          public final Node newNode(int locator,
2837 <                                  Object key, Object value,
2837 >                                  Object key, Object value,
2838                                    CustomConcurrentHashMap cchm,
2839                                    Node linkage) {
2840              if (linkage == null)
# Line 2839 | Line 2844 | public class CustomConcurrentHashMap<K,
2844                  return new LinkedIntKeyIntValueNode
2845                      (locator, key, value, linkage);
2846          }
2847 <    }        
2847 >    }
2848  
2849 <    static abstract class IntKeyWeakValueNode
2849 >    static abstract class IntKeyWeakValueNode
2850          extends IntKeyNode {
2851          volatile EmbeddedWeakReference valueRef;
2852          final CustomConcurrentHashMap cchm;
2853 <        IntKeyWeakValueNode(int locator, Object key, Object value,
2853 >        IntKeyWeakValueNode(int locator, Object key, Object value,
2854                                 CustomConcurrentHashMap cchm) {
2855              super(locator, key);
2856              this.cchm = cchm;
# Line 2857 | Line 2862 | public class CustomConcurrentHashMap<K,
2862          }
2863          public final Object getValue() {
2864              EmbeddedWeakReference vr = valueRef;
2865 <            return vr == null? null : vr.get();
2865 >            return (vr == null) ? null : vr.get();
2866          }
2867          public final void setValue(Object value) {
2868              if (value == null)
# Line 2867 | Line 2872 | public class CustomConcurrentHashMap<K,
2872          }
2873      }
2874  
2875 <    static final class TerminalIntKeyWeakValueNode
2875 >    static final class TerminalIntKeyWeakValueNode
2876          extends IntKeyWeakValueNode {
2877          TerminalIntKeyWeakValueNode(int locator,
2878 <                                       Object key, Object value,
2878 >                                       Object key, Object value,
2879                                         CustomConcurrentHashMap cchm) {
2880              super(locator, key, value, cchm);
2881          }
# Line 2878 | Line 2883 | public class CustomConcurrentHashMap<K,
2883          public final void setLinkage(Node r) { }
2884      }
2885  
2886 <    static final class LinkedIntKeyWeakValueNode
2886 >    static final class LinkedIntKeyWeakValueNode
2887          extends IntKeyWeakValueNode {
2888          volatile Node linkage;
2889          LinkedIntKeyWeakValueNode(int locator,
2890 <                                     Object key, Object value,
2890 >                                     Object key, Object value,
2891                                       CustomConcurrentHashMap cchm,
2892                                       Node linkage) {
2893              super(locator, key, value, cchm);
# Line 2892 | Line 2897 | public class CustomConcurrentHashMap<K,
2897          public final void setLinkage(Node r) { linkage = r; }
2898      }
2899  
2900 <    static final class IntKeyWeakValueNodeFactory
2900 >    static final class IntKeyWeakValueNodeFactory
2901          implements NodeFactory, Serializable {
2902          private static final long serialVersionUID = 7249069346764182397L;
2903 <        public final Node newNode(int locator,
2904 <                                  Object key, Object value,
2903 >        public final Node newNode(int locator,
2904 >                                  Object key, Object value,
2905                                    CustomConcurrentHashMap cchm,
2906                                    Node linkage) {
2907              if (linkage == null)
# Line 2906 | Line 2911 | public class CustomConcurrentHashMap<K,
2911                  return new LinkedIntKeyWeakValueNode
2912                      (locator, key, value, cchm, linkage);
2913          }
2914 <    }        
2914 >    }
2915  
2916  
2917 <    static abstract class IntKeySoftValueNode
2917 >    static abstract class IntKeySoftValueNode
2918          extends IntKeyNode {
2919          volatile EmbeddedSoftReference valueRef;
2920          final CustomConcurrentHashMap cchm;
2921 <        IntKeySoftValueNode(int locator, Object key, Object value,
2922 <                               CustomConcurrentHashMap cchm) {
2921 >        IntKeySoftValueNode(int locator, Object key, Object value,
2922 >                            CustomConcurrentHashMap cchm) {
2923              super(locator, key);
2924              this.cchm = cchm;
2925              if (value != null)
# Line 2925 | Line 2930 | public class CustomConcurrentHashMap<K,
2930          }
2931          public final Object getValue() {
2932              EmbeddedSoftReference vr = valueRef;
2933 <            return vr == null? null : vr.get();
2933 >            return (vr == null) ? null : vr.get();
2934          }
2935          public final void setValue(Object value) {
2936              if (value == null)
# Line 2935 | Line 2940 | public class CustomConcurrentHashMap<K,
2940          }
2941      }
2942  
2943 <    static final class TerminalIntKeySoftValueNode
2943 >    static final class TerminalIntKeySoftValueNode
2944          extends IntKeySoftValueNode {
2945          TerminalIntKeySoftValueNode(int locator,
2946 <                                       Object key, Object value,
2946 >                                       Object key, Object value,
2947                                         CustomConcurrentHashMap cchm) {
2948              super(locator, key, value, cchm);
2949          }
# Line 2946 | Line 2951 | public class CustomConcurrentHashMap<K,
2951          public final void setLinkage(Node r) { }
2952      }
2953  
2954 <    static final class LinkedIntKeySoftValueNode
2954 >    static final class LinkedIntKeySoftValueNode
2955          extends IntKeySoftValueNode {
2956          volatile Node linkage;
2957          LinkedIntKeySoftValueNode(int locator,
2958 <                                     Object key, Object value,
2958 >                                     Object key, Object value,
2959                                       CustomConcurrentHashMap cchm,
2960                                       Node linkage) {
2961              super(locator, key, value, cchm);
# Line 2960 | Line 2965 | public class CustomConcurrentHashMap<K,
2965          public final void setLinkage(Node r) { linkage = r; }
2966      }
2967  
2968 <    static final class IntKeySoftValueNodeFactory
2968 >    static final class IntKeySoftValueNodeFactory
2969          implements NodeFactory, Serializable {
2970          private static final long serialVersionUID = 7249069346764182397L;
2971 <        public final Node newNode(int locator,
2972 <                                  Object key, Object value,
2971 >        public final Node newNode(int locator,
2972 >                                  Object key, Object value,
2973                                    CustomConcurrentHashMap cchm,
2974                                    Node linkage) {
2975              if (linkage == null)
# Line 2974 | Line 2979 | public class CustomConcurrentHashMap<K,
2979                  return new LinkedIntKeySoftValueNode
2980                      (locator, key, value, cchm, linkage);
2981          }
2982 <    }        
2982 >    }
2983  
2984  
2985  
2986      // Temporary Unsafe mechanics for preliminary release
2987  
2988 <    static final Unsafe _unsafe;
2988 >    static final Unsafe UNSAFE;
2989      static final long tableBase;
2990      static final int tableShift;
2991      static final long segmentsBase;
# Line 3011 | Line 3016 | public class CustomConcurrentHashMap<K,
3016  
3017      static {
3018          try {
3019 <            _unsafe = getUnsafe();
3020 <            tableBase = _unsafe.arrayBaseOffset(Node[].class);
3021 <            int s = _unsafe.arrayIndexScale(Node[].class);
3019 >            UNSAFE = getUnsafe();
3020 >            tableBase = UNSAFE.arrayBaseOffset(Node[].class);
3021 >            int s = UNSAFE.arrayIndexScale(Node[].class);
3022              if ((s & (s-1)) != 0)
3023                  throw new Error("data type scale not a power of two");
3024              tableShift = 31 - Integer.numberOfLeadingZeros(s);
3025 <            segmentsBase = _unsafe.arrayBaseOffset(Segment[].class);
3026 <            s = _unsafe.arrayIndexScale(Segment[].class);
3025 >            segmentsBase = UNSAFE.arrayBaseOffset(Segment[].class);
3026 >            s = UNSAFE.arrayIndexScale(Segment[].class);
3027              if ((s & (s-1)) != 0)
3028                  throw new Error("data type scale not a power of two");
3029              segmentsShift = 31 - Integer.numberOfLeadingZeros(s);
# Line 3028 | Line 3033 | public class CustomConcurrentHashMap<K,
3033      }
3034  
3035      // Fenced store into segment table array. Unneeded when we have Fences
3036 <    static final  void storeNode(Node[] table,
3036 >    static final  void storeNode(Node[] table,
3037                                   int i, Node r) {
3038 <        _unsafe.putOrderedObject(table, (i << tableShift) + tableBase, r);
3038 >        long nodeOffset = ((long) i << tableShift) + tableBase;
3039 >        UNSAFE.putOrderedObject(table, nodeOffset, r);
3040      }
3041  
3042 <    static final  void storeSegment(Segment[] segs,
3042 >    static final  void storeSegment(Segment[] segs,
3043                                      int i, Segment s) {
3044 <        _unsafe.putOrderedObject(segs, (i << segmentsShift) + segmentsBase, s);
3044 >        long segmentOffset = ((long) i << segmentsShift) + segmentsBase;
3045 >        UNSAFE.putOrderedObject(segs, segmentOffset, s);
3046      }
3047  
3048  
3049   }
3043

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines