--- old/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Dec 5 14:58:10 2011 +++ new/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Dec 5 14:58:10 2011 @@ -37,9 +37,6 @@ import java.util.concurrent.locks.*; import java.util.*; import java.io.Serializable; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; /** * A hash table supporting full concurrency of retrievals and @@ -228,7 +225,7 @@ static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = HashEntry.class; + Class k = HashEntry.class; nextOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("next")); } catch (Exception e) { @@ -433,7 +430,7 @@ int newCapacity = oldCapacity << 1; threshold = (int)(newCapacity * loadFactor); HashEntry[] newTable = - (HashEntry[]) new HashEntry[newCapacity]; + (HashEntry[]) new HashEntry[newCapacity]; int sizeMask = newCapacity - 1; for (int i = 0; i < oldCapacity ; i++) { HashEntry e = oldTable[i]; @@ -677,7 +674,7 @@ int cap = proto.table.length; float lf = proto.loadFactor; int threshold = (int)(cap * lf); - HashEntry[] tab = (HashEntry[])new HashEntry[cap]; + HashEntry[] tab = (HashEntry[])new HashEntry[cap]; if ((seg = (Segment)UNSAFE.getObjectVolatile(ss, u)) == null) { // recheck Segment s = new Segment(lf, threshold, tab); @@ -694,7 +691,7 @@ // Hash-based segment and entry accesses /** - * Get the segment for the given hash + * Gets the segment for the given hash code. */ @SuppressWarnings("unchecked") private Segment segmentForHash(int h) { @@ -703,7 +700,7 @@ } /** - * Gets the table entry for the given segment and hash + * Gets the table entry for the given segment and hash code. */ @SuppressWarnings("unchecked") static final HashEntry entryForHash(Segment seg, int h) { @@ -758,8 +755,8 @@ // create segments and segments[0] Segment s0 = new Segment(loadFactor, (int)(cap * loadFactor), - (HashEntry[])new HashEntry[cap]); - Segment[] ss = (Segment[])new Segment[ssize]; + (HashEntry[])new HashEntry[cap]); + Segment[] ss = (Segment[])new Segment[ssize]; UNSAFE.putOrderedObject(ss, SBASE, s0); // ordered write of segments[0] this.segments = ss; } @@ -916,6 +913,7 @@ * * @throws NullPointerException if the specified key is null */ + @SuppressWarnings("unchecked") public V get(Object key) { Segment s; // manually integrate access methods to reduce overhead HashEntry[] tab; @@ -1026,7 +1024,7 @@ * full compatibility with class {@link java.util.Hashtable}, * which supported this method prior to introduction of the * Java Collections framework. - + * * @param value a value to search for * @return true if and only if some key maps to the * value argument in this table as @@ -1262,7 +1260,7 @@ } /** - * Set nextEntry to first node of next non-empty table + * Sets nextEntry to first node of next non-empty table * (in backwards order, to simplify checks). */ final void advance() { @@ -1326,12 +1324,14 @@ final class WriteThroughEntry extends AbstractMap.SimpleEntry { + static final long serialVersionUID = 7249069246763182397L; + WriteThroughEntry(K k, V v) { super(k,v); } /** - * Set our entry's value and write through to the map. The + * Sets our entry's value and writes through to the map. The * value to return is somewhat arbitrary here. Since a * WriteThroughEntry does not necessarily track asynchronous * changes, the most recent "previous" value could be @@ -1427,8 +1427,8 @@ /* ---------------- Serialization Support -------------- */ /** - * Save the state of the ConcurrentHashMap instance to a - * stream (i.e., serialize it). + * Saves the state of the ConcurrentHashMap instance to a + * stream (i.e., serializes it). * @param s the stream * @serialData * the key (Object) and value (Object) @@ -1435,7 +1435,8 @@ * for each key-value mapping, followed by a null pair. * The key-value mappings are emitted in no particular order. */ - private void writeObject(java.io.ObjectOutputStream s) throws IOException { + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { // force all segments for serialization compatibility for (int k = 0; k < segments.length; ++k) ensureSegment(k); @@ -1463,13 +1464,13 @@ } /** - * Reconstitute the ConcurrentHashMap instance from a - * stream (i.e., deserialize it). + * Reconstitutes the ConcurrentHashMap instance from a + * stream (i.e., deserializes it). * @param s the stream */ @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException { + throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); // Re-initialize segments to be minimally sized, and let grow. @@ -1479,7 +1480,7 @@ Segment seg = segments[k]; if (seg != null) { seg.threshold = (int)(cap * seg.loadFactor); - seg.table = (HashEntry[]) new HashEntry[cap]; + seg.table = (HashEntry[]) new HashEntry[cap]; } } @@ -1504,8 +1505,8 @@ int ss, ts; try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class tc = HashEntry[].class; - Class sc = Segment[].class; + Class tc = HashEntry[].class; + Class sc = Segment[].class; TBASE = UNSAFE.arrayBaseOffset(tc); SBASE = UNSAFE.arrayBaseOffset(sc); ts = UNSAFE.arrayIndexScale(tc);