Mercurial > hg > openjdk > lambda > jdk
changeset 9544:dc38a743d0e0
Sync j.u.c. from tl.
line wrap: on
line diff
--- a/src/share/classes/java/util/concurrent/ArrayBlockingQueue.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/ArrayBlockingQueue.java Mon Aug 19 18:09:39 2013 +0200 @@ -757,12 +757,8 @@ * Returns an iterator over the elements in this queue in proper sequence. * The elements will be returned in order from first (head) to last (tail). * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this queue in proper sequence */ @@ -1397,14 +1393,17 @@ } /** - * Creates a {@link Spliterator} over the elements in this queue. + * Returns a {@link Spliterator} over the elements in this queue. + * + * <p>The returned spliterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}. * * @implNote * The {@code Spliterator} implements {@code trySplit} to permit limited - * parallelism.. + * parallelism. * * @return a {@code Spliterator} over the elements in this queue * @since 1.8 @@ -1414,4 +1413,5 @@ (this, Spliterator.ORDERED | Spliterator.NONNULL | Spliterator.CONCURRENT); } + }
--- a/src/share/classes/java/util/concurrent/CompletableFuture.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/CompletableFuture.java Mon Aug 19 18:09:39 2013 +0200 @@ -420,6 +420,7 @@ } /** Base class can act as either FJ or plain Runnable */ + @SuppressWarnings("serial") abstract static class Async extends ForkJoinTask<Void> implements Runnable, AsynchronousCompletionTask { public final Void getRawResult() { return null; } @@ -671,6 +672,7 @@ } // Opportunistically subclass AtomicInteger to use compareAndSet to claim. + @SuppressWarnings("serial") abstract static class Completion extends AtomicInteger implements Runnable { }
--- a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Aug 19 18:09:39 2013 +0200 @@ -43,7 +43,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Comparator; -import java.util.ConcurrentModificationException; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; @@ -94,14 +93,14 @@ * that key reporting the updated value.) For aggregate operations * such as {@code putAll} and {@code clear}, concurrent retrievals may * reflect insertion or removal of only some entries. Similarly, - * Iterators and Enumerations return elements reflecting the state of - * the hash table at some point at or since the creation of the + * Iterators, Spliterators and Enumerations return elements reflecting the + * state of the hash table at some point at or since the creation of the * iterator/enumeration. They do <em>not</em> throw {@link - * ConcurrentModificationException}. However, iterators are designed - * to be used by only one thread at a time. Bear in mind that the - * results of aggregate status methods including {@code size}, {@code - * isEmpty}, and {@code containsValue} are typically useful only when - * a map is not undergoing concurrent updates in other threads. + * java.util.ConcurrentModificationException ConcurrentModificationException}. + * However, iterators are designed to be used by only one thread at a time. + * Bear in mind that the results of aggregate status methods including + * {@code size}, {@code isEmpty}, and {@code containsValue} are typically + * useful only when a map is not undergoing concurrent updates in other threads. * Otherwise the results of these methods reflect transient states * that may be adequate for monitoring or estimation purposes, but not * for program control. @@ -1200,11 +1199,8 @@ * operations. It does not support the {@code add} or * {@code addAll} operations. * - * <p>The view's {@code iterator} and {@code spliterator} are a - * "weakly consistent": they will never throw - * {@link ConcurrentModificationException}; are guaranteed to traverse - * elements as they existed upon construction; and may (but is not - * guaranteed to) reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The view's {@code spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#DISTINCT}, and {@link Spliterator#NONNULL}. @@ -1226,11 +1222,8 @@ * {@code retainAll}, and {@code clear} operations. It does not * support the {@code add} or {@code addAll} operations. * - * <p>The view's {@code iterator} and {@code spliterator} are a - * "weakly consistent": they will never throw - * {@link ConcurrentModificationException}; are guaranteed to traverse - * elements as they existed upon construction; and may (but is not - * guaranteed to) reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The view's {@code spliterator} reports {@link Spliterator#CONCURRENT} * and {@link Spliterator#NONNULL}. @@ -1251,11 +1244,8 @@ * {@code removeAll}, {@code retainAll}, and {@code clear} * operations. * - * <p>The view's {@code iterator} and {@code spliterator} are a - * "weakly consistent": they will never throw - * {@link ConcurrentModificationException}; are guaranteed to traverse - * elements as they existed upon construction; and may (but is not - * guaranteed to) reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The view's {@code spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#DISTINCT}, and {@link Spliterator#NONNULL}. @@ -2794,7 +2784,7 @@ return; } } - else if ((s | WAITER) == 0) { + else if ((s & WAITER) == 0) { if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) { waiting = true; waiter = Thread.currentThread(); @@ -4317,12 +4307,12 @@ // implementations below rely on concrete classes supplying these // abstract methods /** - * Returns a "weakly consistent" iterator that will never - * throw {@link ConcurrentModificationException}, and - * guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not - * guaranteed to) reflect any modifications subsequent to - * construction. + * Returns an iterator over the elements in this collection. + * + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. + * + * @return an iterator over the elements in this collection */ public abstract Iterator<E> iterator(); public abstract boolean contains(Object o); @@ -4725,6 +4715,7 @@ * Base class for bulk tasks. Repeats some fields and code from * class Traverser, because we need to subclass CountedCompleter. */ + @SuppressWarnings("serial") abstract static class BulkTask<K,V,R> extends CountedCompleter<R> { Node<K,V>[] tab; // same as Traverser Node<K,V> next;
--- a/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java Mon Aug 19 18:09:39 2013 +0200 @@ -55,12 +55,8 @@ * Like most other concurrent collection implementations, this class * does not permit the use of {@code null} elements. * - * <p>Iterators are <i>weakly consistent</i>, returning elements - * reflecting the state of the deque at some point at or since the - * creation of the iterator. They do <em>not</em> throw {@link - * java.util.ConcurrentModificationException - * ConcurrentModificationException}, and may proceed concurrently with - * other operations. + * <p>Iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>Beware that, unlike in most collections, the {@code size} method * is <em>NOT</em> a constant-time operation. Because of the @@ -1290,12 +1286,8 @@ * Returns an iterator over the elements in this deque in proper sequence. * The elements will be returned in order from first (head) to last (tail). * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this deque in proper sequence */ @@ -1308,12 +1300,8 @@ * sequential order. The elements will be returned in order from * last (tail) to first (head). * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this deque in reverse order */ @@ -1494,14 +1482,17 @@ } /** - * Creates a {@link Spliterator} over the elements in this deque. + * Returns a {@link Spliterator} over the elements in this deque. + * + * <p>The returned spliterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}. * * @implNote * The {@code Spliterator} implements {@code trySplit} to permit limited - * parallelism.. + * parallelism. * * @return a {@code Spliterator} over the elements in this deque * @since 1.8 @@ -1513,6 +1504,8 @@ /** * Saves this deque to a stream (that is, serializes it). * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs * @serialData All of the elements (each an {@code E}) in * the proper order, followed by a null */ @@ -1535,6 +1528,10 @@ /** * Reconstitutes this deque from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
--- a/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java Mon Aug 19 18:09:39 2013 +0200 @@ -654,12 +654,8 @@ * Returns an iterator over the elements in this queue in proper sequence. * The elements will be returned in order from first (head) to last (tail). * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this queue in proper sequence */ @@ -749,6 +745,8 @@ /** * Saves this queue to a stream (that is, serializes it). * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs * @serialData All of the elements (each an {@code E}) in * the proper order, followed by a null */ @@ -771,6 +769,10 @@ /** * Reconstitutes this queue from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { @@ -882,14 +884,17 @@ } /** - * Creates a {@link Spliterator} over the elements in this queue. + * Returns a {@link Spliterator} over the elements in this queue. + * + * <p>The returned spliterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}. * * @implNote * The {@code Spliterator} implements {@code trySplit} to permit limited - * parallelism.. + * parallelism. * * @return a {@code Spliterator} over the elements in this queue * @since 1.8
--- a/src/share/classes/java/util/concurrent/ConcurrentNavigableMap.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/ConcurrentNavigableMap.java Mon Aug 19 18:09:39 2013 +0200 @@ -120,11 +120,8 @@ * operations. It does not support the {@code add} or {@code addAll} * operations. * - * <p>The view's {@code iterator} is a "weakly consistent" iterator - * that will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return a navigable set view of the keys in this map */ @@ -141,11 +138,8 @@ * operations. It does not support the {@code add} or {@code addAll} * operations. * - * <p>The view's {@code iterator} is a "weakly consistent" iterator - * that will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>This method is equivalent to method {@code navigableKeySet}. * @@ -164,11 +158,8 @@ * operations. It does not support the {@code add} or {@code addAll} * operations. * - * <p>The view's {@code iterator} is a "weakly consistent" iterator - * that will never throw {@link ConcurrentModificationException}, - * and guarantees to traverse elements as they existed upon - * construction of the iterator, and may (but is not guaranteed to) - * reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return a reverse order navigable set view of the keys in this map */
--- a/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java Mon Aug 19 18:09:39 2013 +0200 @@ -45,11 +45,15 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.NavigableMap; import java.util.NavigableSet; import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedMap; +import java.util.SortedSet; import java.util.Spliterator; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentNavigableMap; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.BiConsumer; @@ -67,12 +71,13 @@ * {@code containsKey}, {@code get}, {@code put} and * {@code remove} operations and their variants. Insertion, removal, * update, and access operations safely execute concurrently by - * multiple threads. Iterators are <i>weakly consistent</i>, returning - * elements reflecting the state of the map at some point at or since - * the creation of the iterator. They do <em>not</em> throw {@link - * java.util.ConcurrentModificationException ConcurrentModificationException}, - * and may proceed concurrently with other operations. Ascending key ordered - * views and their iterators are faster than descending ones. + * multiple threads. + * + * <p>Iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. + * + * <p>Ascending key ordered views and their iterators are faster than + * descending ones. * * <p>All {@code Map.Entry} pairs returned by methods in this class * and its views represent snapshots of mappings at the time they were @@ -109,9 +114,7 @@ * @since 1.6 */ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V> - implements ConcurrentNavigableMap<K,V>, - Cloneable, - java.io.Serializable { + implements ConcurrentNavigableMap<K,V>, Cloneable, Serializable { /* * This class implements a tree-like two-dimensionally linked skip * list in which the index levels are represented in separate @@ -1413,6 +1416,8 @@ /** * Saves this map to a stream (that is, serializes it). * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs * @serialData The key (Object) and value (Object) for each * key-value mapping represented by the map, followed by * {@code null}. The key-value mappings are emitted in key-order @@ -1437,6 +1442,10 @@ /** * Reconstitutes this map from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ @SuppressWarnings("unchecked") private void readObject(final java.io.ObjectInputStream s) @@ -1800,7 +1809,7 @@ * <p>The set's iterator returns the keys in ascending order. * The set's spliterator additionally reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#NONNULL}, {@link Spliterator#SORTED} and - * {@link Spliterator#ORDERED} with an encounter order that is ascending + * {@link Spliterator#ORDERED}, with an encounter order that is ascending * key order. The spliterator's comparator (see * {@link java.util.Spliterator#getComparator()}) is {@code null} if * the map's comparator (see {@link #comparator()}) is {@code null}. @@ -1815,11 +1824,8 @@ * operations. It does not support the {@code add} or {@code addAll} * operations. * - * <p>The view's {@code iterator} and {@code spliterator} are a - * "weakly consistent": they will never throw - * {@link java.util.ConcurrentModificationException}; are guaranteed to - * traverse elements as they existed upon construction; and may (but is not - * guaranteed to) reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>This method is equivalent to method {@code navigableKeySet}. * @@ -1837,11 +1843,10 @@ /** * Returns a {@link Collection} view of the values contained in this map. - * * <p>The collection's iterator returns the values in ascending order * of the corresponding keys. The collections's spliterator additionally - * reports {@link Spliterator#CONCURRENT}, {@link Spliterator#NONNULL}, and - * {@link Spliterator#ORDERED} with an encounter order that is ascending + * reports {@link Spliterator#CONCURRENT}, {@link Spliterator#NONNULL} and + * {@link Spliterator#ORDERED}, with an encounter order that is ascending * order of the corresponding keys. * * <p>The collection is backed by the map, so changes to the map are @@ -1852,11 +1857,8 @@ * {@code retainAll} and {@code clear} operations. It does not * support the {@code add} or {@code addAll} operations. * - * <p>The view's {@code iterator} and {@code spliterator} are a - * "weakly consistent": they will never throw - * {@link java.util.ConcurrentModificationException}; are guaranteed to - * traverse elements as they existed upon construction; and may (but is not - * guaranteed to) reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. */ public Collection<V> values() { Values<V> vs = values; @@ -1868,8 +1870,8 @@ * * <p>The set's iterator returns the entries in ascending key order. The * set's spliterator additionally reports {@link Spliterator#CONCURRENT}, - * {@link Spliterator#NONNULL}, {@link Spliterator#SORTED}, and - * {@link Spliterator#ORDERED} with an encounter order that is ascending + * {@link Spliterator#NONNULL}, {@link Spliterator#SORTED} and + * {@link Spliterator#ORDERED}, with an encounter order that is ascending * key order. * * <p>The set is backed by the map, so changes to the map are @@ -1880,11 +1882,8 @@ * operations. It does not support the {@code add} or * {@code addAll} operations. * - * <p>The view's {@code iterator} and {@code spliterator} are a - * "weakly consistent": they will never throw - * {@link java.util.ConcurrentModificationException}; are guaranteed to - * traverse elements as they existed upon construction; and may (but is not - * guaranteed to) reflect any modifications subsequent to construction. + * <p>The view's iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The {@code Map.Entry} elements traversed by the {@code iterator} * or {@code spliterator} do <em>not</em> support the {@code setValue} @@ -2570,8 +2569,7 @@ * @serial include */ static final class SubMap<K,V> extends AbstractMap<K,V> - implements ConcurrentNavigableMap<K,V>, Cloneable, - java.io.Serializable { + implements ConcurrentNavigableMap<K,V>, Cloneable, Serializable { private static final long serialVersionUID = -7647078645895051609L; /** Underlying map */ @@ -3202,6 +3200,7 @@ public long estimateSize() { return Long.MAX_VALUE; } + } final class SubMapValueIterator extends SubMapIter<V> { @@ -3552,11 +3551,11 @@ public final Comparator<Map.Entry<K,V>> getComparator() { // Adapt or create a key-based comparator - if (comparator != null) { + if (comparator != null) { return Map.Entry.comparingByKey(comparator); } else { - return (Comparator<Map.Entry<K, V>> & Serializable) (e1, e2) -> { + return (Comparator<Map.Entry<K,V>> & Serializable) (e1, e2) -> { @SuppressWarnings("unchecked") Comparable<? super K> k1 = (Comparable<? super K>) e1.getKey(); return k1.compareTo(e2.getKey());
--- a/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java Mon Aug 19 18:09:39 2013 +0200 @@ -57,12 +57,12 @@ * cost for the {@code contains}, {@code add}, and {@code remove} * operations and their variants. Insertion, removal, and access * operations safely execute concurrently by multiple threads. - * Iterators are <i>weakly consistent</i>, returning elements - * reflecting the state of the set at some point at or since the - * creation of the iterator. They do <em>not</em> throw {@link - * java.util.ConcurrentModificationException}, and may proceed - * concurrently with other operations. Ascending ordered views and - * their iterators are faster than descending ones. + * + * <p>Iterators and spliterators are + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. + * + * <p>Ascending ordered views and their iterators are faster than + * descending ones. * * <p>Beware that, unlike in most collections, the {@code size} * method is <em>not</em> a constant-time operation. Because of the @@ -481,11 +481,11 @@ } /** - * Creates a {@link Spliterator} over the elements in this set. + * Returns a {@link Spliterator} over the elements in this set. * * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#NONNULL}, {@link Spliterator#DISTINCT}, - * {@link Spliterator#SORTED}, and {@link Spliterator#ORDERED} with an + * {@link Spliterator#SORTED} and {@link Spliterator#ORDERED}, with an * encounter order that is ascending order. Overriding implementations * should document the reporting of additional characteristic values. *
--- a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java Mon Aug 19 18:09:39 2013 +0200 @@ -952,6 +952,8 @@ /** * Saves this list to a stream (that is, serializes it). * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs * @serialData The length of the array backing the list is emitted * (int), followed by all of its elements (each an Object) * in the proper order. @@ -972,6 +974,10 @@ /** * Reconstitutes this list from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { @@ -1092,17 +1098,17 @@ * * @throws IndexOutOfBoundsException {@inheritDoc} */ - public ListIterator<E> listIterator(final int index) { + public ListIterator<E> listIterator(int index) { Object[] elements = getArray(); int len = elements.length; - if (index<0 || index>len) + if (index < 0 || index > len) throw new IndexOutOfBoundsException("Index: "+index); return new COWIterator<E>(elements, index); } /** - * Creates a {@link Spliterator} over the elements in this list. + * Returns a {@link Spliterator} over the elements in this list. * * <p>The {@code Spliterator} reports {@link Spliterator#IMMUTABLE}, * {@link Spliterator#ORDERED}, {@link Spliterator#SIZED}, and @@ -1110,8 +1116,7 @@ * * <p>The spliterator provides a snapshot of the state of the list * when the spliterator was constructed. No synchronization is needed while - * operating on the spliterator. The spliterator does <em>NOT</em> support - * the {@code remove}, {@code set} or {@code add} methods. + * operating on the spliterator. * * @return a {@code Spliterator} over the elements in this list * @since 1.8 @@ -1272,7 +1277,7 @@ // only call this holding l's lock private void rangeCheck(int index) { - if (index<0 || index>=size) + if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: "+index+ ",Size: "+size); } @@ -1319,7 +1324,7 @@ lock.lock(); try { checkForComodification(); - if (index<0 || index>size) + if (index < 0 || index > size) throw new IndexOutOfBoundsException(); l.add(index+offset, element); expectedArray = l.getArray(); @@ -1376,12 +1381,12 @@ } } - public ListIterator<E> listIterator(final int index) { + public ListIterator<E> listIterator(int index) { final ReentrantLock lock = l.lock; lock.lock(); try { checkForComodification(); - if (index<0 || index>size) + if (index < 0 || index > size) throw new IndexOutOfBoundsException("Index: "+index+ ", Size: "+size); return new COWSubListIterator<E>(l, index, offset, size); @@ -1395,7 +1400,7 @@ lock.lock(); try { checkForComodification(); - if (fromIndex<0 || toIndex>size) + if (fromIndex < 0 || toIndex > size) throw new IndexOutOfBoundsException(); return new COWSubList<E>(l, fromIndex + offset, toIndex + offset); @@ -1595,6 +1600,7 @@ return Spliterators.spliterator (a, lo, hi, Spliterator.IMMUTABLE | Spliterator.ORDERED); } + } private static class COWSubListIterator<E> implements ListIterator<E> {
--- a/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java Mon Aug 19 18:09:39 2013 +0200 @@ -405,7 +405,7 @@ } /** - * Creates a {@link Spliterator} over the elements in this set in the order + * Returns a {@link Spliterator} over the elements in this set in the order * in which these elements were added. * * <p>The {@code Spliterator} reports {@link Spliterator#IMMUTABLE}, @@ -414,10 +414,9 @@ * * <p>The spliterator provides a snapshot of the state of the set * when the spliterator was constructed. No synchronization is needed while - * operating on the spliterator. The spliterator does <em>NOT</em> support - * the {@code remove}, {@code set} or {@code add} methods. + * operating on the spliterator. * - * @return a {@code Spliterator} over the elements in this list + * @return a {@code Spliterator} over the elements in this set * @since 1.8 */ public Spliterator<E> spliterator() {
--- a/src/share/classes/java/util/concurrent/DelayQueue.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/DelayQueue.java Mon Aug 19 18:09:39 2013 +0200 @@ -512,12 +512,8 @@ * unexpired) in this queue. The iterator does not return the * elements in any particular order. * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this queue */
--- a/src/share/classes/java/util/concurrent/ForkJoinPool.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/ForkJoinPool.java Mon Aug 19 18:09:39 2013 +0200 @@ -144,7 +144,8 @@ * Upon any error in establishing these settings, default parameters * are used. It is possible to disable or limit the use of threads in * the common pool by setting the parallelism property to zero, and/or - * using a factory that may return {@code null}. + * using a factory that may return {@code null}. However doing so may + * cause unjoined tasks to never be executed. * * <p><b>Implementation notes</b>: This implementation restricts the * maximum number of running threads to 32767. Attempts to create @@ -3303,8 +3304,8 @@ } if (parallelism < 0 && // default 1 less than #cores - (parallelism = Runtime.getRuntime().availableProcessors() - 1) < 0) - parallelism = 0; + (parallelism = Runtime.getRuntime().availableProcessors() - 1) <= 0) + parallelism = 1; if (parallelism > MAX_CAP) parallelism = MAX_CAP; return new ForkJoinPool(parallelism, factory, handler, LIFO_QUEUE,
--- a/src/share/classes/java/util/concurrent/LinkedBlockingDeque.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/LinkedBlockingDeque.java Mon Aug 19 18:09:39 2013 +0200 @@ -1008,12 +1008,8 @@ * Returns an iterator over the elements in this deque in proper sequence. * The elements will be returned in order from first (head) to last (tail). * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this deque in proper sequence */ @@ -1026,12 +1022,8 @@ * sequential order. The elements will be returned in order from * last (tail) to first (head). * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this deque in reverse order */ @@ -1271,14 +1263,17 @@ } /** - * Creates a {@link Spliterator} over the elements in this deque. + * Returns a {@link Spliterator} over the elements in this deque. + * + * <p>The returned spliterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}. * * @implNote * The {@code Spliterator} implements {@code trySplit} to permit limited - * parallelism.. + * parallelism. * * @return a {@code Spliterator} over the elements in this deque * @since 1.8 @@ -1290,6 +1285,8 @@ /** * Saves this deque to a stream (that is, serializes it). * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs * @serialData The capacity (int), followed by elements (each an * {@code Object}) in the proper order, followed by a null */ @@ -1312,6 +1309,10 @@ /** * Reconstitutes this deque from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
--- a/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java Mon Aug 19 18:09:39 2013 +0200 @@ -766,12 +766,8 @@ * Returns an iterator over the elements in this queue in proper sequence. * The elements will be returned in order from first (head) to last (tail). * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this queue in proper sequence */ @@ -974,14 +970,17 @@ } /** - * Creates a {@link Spliterator} over the elements in this queue. + * Returns a {@link Spliterator} over the elements in this queue. + * + * <p>The returned spliterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}. * * @implNote * The {@code Spliterator} implements {@code trySplit} to permit limited - * parallelism.. + * parallelism. * * @return a {@code Spliterator} over the elements in this queue * @since 1.8 @@ -993,6 +992,8 @@ /** * Saves this queue to a stream (that is, serializes it). * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs * @serialData The capacity is emitted (int), followed by all of * its elements (each an {@code Object}) in the proper order, * followed by a null @@ -1018,6 +1019,10 @@ /** * Reconstitutes this queue from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
--- a/src/share/classes/java/util/concurrent/LinkedTransferQueue.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/LinkedTransferQueue.java Mon Aug 19 18:09:39 2013 +0200 @@ -40,6 +40,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Queue; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.LockSupport; import java.util.Spliterator; import java.util.Spliterators; @@ -1019,14 +1020,17 @@ } /** - * Creates a {@link Spliterator} over the elements in this queue. + * Returns a {@link Spliterator} over the elements in this queue. + * + * <p>The returned spliterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT}, * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}. * * @implNote * The {@code Spliterator} implements {@code trySplit} to permit limited - * parallelism.. + * parallelism. * * @return a {@code Spliterator} over the elements in this queue * @since 1.8 @@ -1314,12 +1318,8 @@ * Returns an iterator over the elements in this queue in proper sequence. * The elements will be returned in order from first (head) to last (tail). * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this queue in proper sequence */ @@ -1420,6 +1420,8 @@ /** * Saves this queue to a stream (that is, serializes it). * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs * @serialData All of the elements (each an {@code E}) in * the proper order, followed by a null */ @@ -1434,6 +1436,10 @@ /** * Reconstitutes this queue from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
--- a/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java Mon Aug 19 18:09:39 2013 +0200 @@ -229,7 +229,7 @@ /** * Creates a {@code PriorityBlockingQueue} containing the elements * in the specified collection. If the specified collection is a - * {@link SortedSet} or a {@link PriorityQueue}, this + * {@link SortedSet} or a {@link PriorityQueue}, this * priority queue will be ordered according to the same ordering. * Otherwise, this priority queue will be ordered according to the * {@linkplain Comparable natural ordering} of its elements. @@ -864,12 +864,8 @@ * Returns an iterator over the elements in this queue. The * iterator does not return the elements in any particular order. * - * <p>The returned iterator is a "weakly consistent" iterator that - * will never throw {@link java.util.ConcurrentModificationException - * ConcurrentModificationException}, and guarantees to traverse - * elements as they existed upon construction of the iterator, and - * may (but is not guaranteed to) reflect any modifications - * subsequent to construction. + * <p>The returned iterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * @return an iterator over the elements in this queue */ @@ -915,6 +911,9 @@ * For compatibility with previous version of this class, elements * are first copied to a java.util.PriorityQueue, which is then * serialized. + * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs */ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { @@ -932,6 +931,10 @@ /** * Reconstitutes this queue from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { @@ -1006,7 +1009,10 @@ } /** - * Creates a {@link Spliterator} over the elements in this queue. + * Returns a {@link Spliterator} over the elements in this queue. + * + * <p>The returned spliterator is + * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. * * <p>The {@code Spliterator} reports {@link Spliterator#SIZED} and * {@link Spliterator#NONNULL}.
--- a/src/share/classes/java/util/concurrent/SynchronousQueue.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/SynchronousQueue.java Mon Aug 19 18:09:39 2013 +0200 @@ -38,6 +38,8 @@ import java.util.concurrent.locks.LockSupport; import java.util.concurrent.locks.ReentrantLock; import java.util.*; +import java.util.Spliterator; +import java.util.Spliterators; /** * A {@linkplain BlockingQueue blocking queue} in which each insert @@ -1062,26 +1064,16 @@ * * @return an empty iterator */ - @SuppressWarnings("unchecked") public Iterator<E> iterator() { - return (Iterator<E>) EmptyIterator.EMPTY_ITERATOR; - } - - // Replicated from a previous version of Collections - private static class EmptyIterator<E> implements Iterator<E> { - static final EmptyIterator<Object> EMPTY_ITERATOR - = new EmptyIterator<Object>(); - - public boolean hasNext() { return false; } - public E next() { throw new NoSuchElementException(); } - public void remove() { throw new IllegalStateException(); } + return Collections.emptyIterator(); } /** - * Return an empty spliterator in which calls to + * Returns an empty spliterator in which calls to * {@link java.util.Spliterator#trySplit()} always return {@code null}. * - * @return an empty spliterator. + * @return an empty spliterator + * @since 1.8 */ public Spliterator<E> spliterator() { return Spliterators.emptySpliterator(); @@ -1169,6 +1161,8 @@ /** * Saves this queue to a stream (that is, serializes it). + * @param s the stream + * @throws java.io.IOException if an I/O error occurs */ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { @@ -1188,8 +1182,12 @@ /** * Reconstitutes this queue from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs */ - private void readObject(final java.io.ObjectInputStream s) + private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); if (waitingProducers instanceof FifoWaitQueue)
--- a/src/share/classes/java/util/concurrent/atomic/Striped64.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/atomic/Striped64.java Mon Aug 19 18:09:39 2013 +0200 @@ -43,6 +43,7 @@ * for classes supporting dynamic striping on 64bit values. The class * extends Number so that concrete subclasses must publicly do so. */ +@SuppressWarnings("serial") abstract class Striped64 extends Number { /* * This class maintains a lazily-initialized table of atomically
--- a/src/share/classes/java/util/concurrent/package-info.java Mon Aug 19 14:48:29 2013 +0200 +++ b/src/share/classes/java/util/concurrent/package-info.java Mon Aug 19 18:09:39 2013 +0200 @@ -210,13 +210,19 @@ * collections are unshared, or are accessible only when * holding other locks. * - * <p>Most concurrent Collection implementations (including most - * Queues) also differ from the usual java.util conventions in that - * their Iterators provide <em>weakly consistent</em> rather than - * fast-fail traversal. A weakly consistent iterator is thread-safe, - * but does not necessarily freeze the collection while iterating, so - * it may (or may not) reflect any updates since the iterator was - * created. + * <p id="Weakly">Most concurrent Collection implementations + * (including most Queues) also differ from the usual {@code java.util} + * conventions in that their {@linkplain java.util.Iterator Iterators} + * and {@linkplain java.util.Spliterator Spliterators} provide + * <em>weakly consistent</em> rather than fast-fail traversal: + * <ul> + * <li>they may proceed concurrently with other operations + * <li>they will never throw {@link java.util.ConcurrentModificationException + * ConcurrentModificationException} + * <li>they are guaranteed to traverse elements as they existed upon + * construction exactly once, and may (but are not guaranteed to) + * reflect any modifications subsequent to construction. + * </ul> * * <h2 id="MemoryVisibility">Memory Consistency Properties</h2> *