diff --git a/src/share/classes/java/util/AbstractCollection.java b/src/share/classes/java/util/AbstractCollection.java index 427f42739b227eeca4b11e6b48503261240ac211..9b675d756e6d86b0120e5d399ca19ed4049d271f 100644 --- a/src/share/classes/java/util/AbstractCollection.java +++ b/src/share/classes/java/util/AbstractCollection.java @@ -96,14 +96,14 @@ public abstract class AbstractCollection implements Collection { * @throws NullPointerException {@inheritDoc} */ public boolean contains(Object o) { - Iterator e = iterator(); + Iterator it = iterator(); if (o==null) { - while (e.hasNext()) - if (e.next()==null) + while (it.hasNext()) + if (it.next()==null) return true; } else { - while (e.hasNext()) - if (o.equals(e.next())) + while (it.hasNext()) + if (o.equals(it.next())) return true; } return false; @@ -269,18 +269,18 @@ public abstract class AbstractCollection implements Collection { * @throws NullPointerException {@inheritDoc} */ public boolean remove(Object o) { - Iterator e = iterator(); + Iterator it = iterator(); if (o==null) { - while (e.hasNext()) { - if (e.next()==null) { - e.remove(); + while (it.hasNext()) { + if (it.next()==null) { + it.remove(); return true; } } } else { - while (e.hasNext()) { - if (o.equals(e.next())) { - e.remove(); + while (it.hasNext()) { + if (o.equals(it.next())) { + it.remove(); return true; } } @@ -304,9 +304,8 @@ public abstract class AbstractCollection implements Collection { * @see #contains(Object) */ public boolean containsAll(Collection c) { - Iterator e = c.iterator(); - while (e.hasNext()) - if (!contains(e.next())) + for (Object e : c) + if (!contains(e)) return false; return true; } @@ -331,11 +330,9 @@ public abstract class AbstractCollection implements Collection { */ public boolean addAll(Collection c) { boolean modified = false; - Iterator e = c.iterator(); - while (e.hasNext()) { - if (add(e.next())) + for (E e : c) + if (add(e)) modified = true; - } return modified; } @@ -362,10 +359,10 @@ public abstract class AbstractCollection implements Collection { */ public boolean removeAll(Collection c) { boolean modified = false; - Iterator e = iterator(); - while (e.hasNext()) { - if (c.contains(e.next())) { - e.remove(); + Iterator it = iterator(); + while (it.hasNext()) { + if (c.contains(it.next())) { + it.remove(); modified = true; } } @@ -395,10 +392,10 @@ public abstract class AbstractCollection implements Collection { */ public boolean retainAll(Collection c) { boolean modified = false; - Iterator e = iterator(); - while (e.hasNext()) { - if (!c.contains(e.next())) { - e.remove(); + Iterator it = iterator(); + while (it.hasNext()) { + if (!c.contains(it.next())) { + it.remove(); modified = true; } } @@ -421,10 +418,10 @@ public abstract class AbstractCollection implements Collection { * @throws UnsupportedOperationException {@inheritDoc} */ public void clear() { - Iterator e = iterator(); - while (e.hasNext()) { - e.next(); - e.remove(); + Iterator it = iterator(); + while (it.hasNext()) { + it.next(); + it.remove(); } } @@ -442,18 +439,18 @@ public abstract class AbstractCollection implements Collection { * @return a string representation of this collection */ public String toString() { - Iterator i = iterator(); - if (! i.hasNext()) + Iterator it = iterator(); + if (! it.hasNext()) return "[]"; StringBuilder sb = new StringBuilder(); sb.append('['); for (;;) { - E e = i.next(); + E e = it.next(); sb.append(e == this ? "(this Collection)" : e); - if (! i.hasNext()) + if (! it.hasNext()) return sb.append(']').toString(); - sb.append(", "); + sb.append(',').append(' '); } } diff --git a/src/share/classes/java/util/AbstractList.java b/src/share/classes/java/util/AbstractList.java index c0304df1561b6ef0d3f3b228100c5a3b2d30efd4..9752de1d08f027480eebecfced1c50ece40fd20e 100644 --- a/src/share/classes/java/util/AbstractList.java +++ b/src/share/classes/java/util/AbstractList.java @@ -175,15 +175,15 @@ public abstract class AbstractList extends AbstractCollection implements L * @throws NullPointerException {@inheritDoc} */ public int indexOf(Object o) { - ListIterator e = listIterator(); + ListIterator it = listIterator(); if (o==null) { - while (e.hasNext()) - if (e.next()==null) - return e.previousIndex(); + while (it.hasNext()) + if (it.next()==null) + return it.previousIndex(); } else { - while (e.hasNext()) - if (o.equals(e.next())) - return e.previousIndex(); + while (it.hasNext()) + if (o.equals(it.next())) + return it.previousIndex(); } return -1; } @@ -200,15 +200,15 @@ public abstract class AbstractList extends AbstractCollection implements L * @throws NullPointerException {@inheritDoc} */ public int lastIndexOf(Object o) { - ListIterator e = listIterator(size()); + ListIterator it = listIterator(size()); if (o==null) { - while (e.hasPrevious()) - if (e.previous()==null) - return e.nextIndex(); + while (it.hasPrevious()) + if (it.previous()==null) + return it.nextIndex(); } else { - while (e.hasPrevious()) - if (o.equals(e.previous())) - return e.nextIndex(); + while (it.hasPrevious()) + if (o.equals(it.previous())) + return it.nextIndex(); } return -1; } @@ -517,7 +517,7 @@ public abstract class AbstractList extends AbstractCollection implements L ListIterator e1 = listIterator(); ListIterator e2 = ((List) o).listIterator(); - while(e1.hasNext() && e2.hasNext()) { + while (e1.hasNext() && e2.hasNext()) { E o1 = e1.next(); Object o2 = e2.next(); if (!(o1==null ? o2==null : o1.equals(o2))) diff --git a/src/share/classes/java/util/AbstractMap.java b/src/share/classes/java/util/AbstractMap.java index 43c801a8093ece3e3d890677a9c164a03de37b5f..431313e8ff4b3ba4a259a67159743dbf5d09415f 100644 --- a/src/share/classes/java/util/AbstractMap.java +++ b/src/share/classes/java/util/AbstractMap.java @@ -523,7 +523,7 @@ public abstract class AbstractMap implements Map { sb.append(value == this ? "(this Map)" : value); if (! i.hasNext()) return sb.append('}').toString(); - sb.append(", "); + sb.append(',').append(' '); } } diff --git a/src/share/classes/java/util/ArrayList.java b/src/share/classes/java/util/ArrayList.java index 7c6eded3a830094f02f422bb6a2945e3c4efc494..45ca44296ca42882b6ef7268a6ca7d27b07cb1b9 100644 --- a/src/share/classes/java/util/ArrayList.java +++ b/src/share/classes/java/util/ArrayList.java @@ -120,9 +120,9 @@ public class ArrayList extends AbstractList /** * Constructs an empty list with the specified initial capacity. * - * @param initialCapacity the initial capacity of the list - * @exception IllegalArgumentException if the specified initial capacity - * is negative + * @param initialCapacity the initial capacity of the list + * @throws IllegalArgumentException if the specified initial capacity + * is negative */ public ArrayList(int initialCapacity) { super(); @@ -173,7 +173,7 @@ public class ArrayList extends AbstractList * necessary, to ensure that it can hold at least the number of elements * specified by the minimum capacity argument. * - * @param minCapacity the desired minimum capacity + * @param minCapacity the desired minimum capacity */ public void ensureCapacity(int minCapacity) { if (minCapacity > 0) diff --git a/src/share/classes/java/util/Collections.java b/src/share/classes/java/util/Collections.java index e4329dc0e43d83295acf48d6918aa927aae94af8..c5d8476c8a35613fe4ec4f6bc3991a667861335d 100644 --- a/src/share/classes/java/util/Collections.java +++ b/src/share/classes/java/util/Collections.java @@ -124,7 +124,7 @@ public class Collections { * *

The implementation takes equal advantage of ascending and * descending order in its input array, and can take advantage of - * ascending and descending order in different parts of the the same + * ascending and descending order in different parts of the same * input array. It is well-suited to merging two or more sorted arrays: * simply concatenate the arrays and sort the resulting array. * @@ -184,7 +184,7 @@ public class Collections { * *

The implementation takes equal advantage of ascending and * descending order in its input array, and can take advantage of - * ascending and descending order in different parts of the the same + * ascending and descending order in different parts of the same * input array. It is well-suited to merging two or more sorted arrays: * simply concatenate the arrays and sort the resulting array. * @@ -823,7 +823,7 @@ public class Collections { i -= size; displaced = list.set(i, displaced); nMoved ++; - } while(i != cycleStart); + } while (i != cycleStart); } } @@ -1452,9 +1452,9 @@ public class Collections { * when o is a Map.Entry, and calls o.setValue. */ public boolean containsAll(Collection coll) { - Iterator e = coll.iterator(); - while (e.hasNext()) - if (!contains(e.next())) // Invokes safe contains() above + Iterator it = coll.iterator(); + while (it.hasNext()) + if (!contains(it.next())) // Invokes safe contains() above return false; return true; } @@ -1482,12 +1482,12 @@ public class Collections { UnmodifiableEntry(Map.Entry e) {this.e = e;} - public K getKey() {return e.getKey();} - public V getValue() {return e.getValue();} + public K getKey() {return e.getKey();} + public V getValue() {return e.getValue();} public V setValue(V value) { throw new UnsupportedOperationException(); } - public int hashCode() {return e.hashCode();} + public int hashCode() {return e.hashCode();} public boolean equals(Object o) { if (!(o instanceof Map.Entry)) return false; @@ -1495,7 +1495,7 @@ public class Collections { return eq(e.getKey(), t.getKey()) && eq(e.getValue(), t.getValue()); } - public String toString() {return e.toString();} + public String toString() {return e.toString();} } } } @@ -1562,7 +1562,7 @@ public class Collections { *

      *  Collection c = Collections.synchronizedCollection(myCollection);
      *     ...
-     *  synchronized(c) {
+     *  synchronized (c) {
      *      Iterator i = c.iterator(); // Must be in the synchronized block
      *      while (i.hasNext())
      *         foo(i.next());
@@ -1611,19 +1611,19 @@ public class Collections {
         }
 
         public int size() {
-            synchronized(mutex) {return c.size();}
+            synchronized (mutex) {return c.size();}
         }
         public boolean isEmpty() {
-            synchronized(mutex) {return c.isEmpty();}
+            synchronized (mutex) {return c.isEmpty();}
         }
         public boolean contains(Object o) {
-            synchronized(mutex) {return c.contains(o);}
+            synchronized (mutex) {return c.contains(o);}
         }
         public Object[] toArray() {
-            synchronized(mutex) {return c.toArray();}
+            synchronized (mutex) {return c.toArray();}
         }
         public  T[] toArray(T[] a) {
-            synchronized(mutex) {return c.toArray(a);}
+            synchronized (mutex) {return c.toArray(a);}
         }
 
         public Iterator iterator() {
@@ -1631,32 +1631,32 @@ public class Collections {
         }
 
         public boolean add(E e) {
-            synchronized(mutex) {return c.add(e);}
+            synchronized (mutex) {return c.add(e);}
         }
         public boolean remove(Object o) {
-            synchronized(mutex) {return c.remove(o);}
+            synchronized (mutex) {return c.remove(o);}
         }
 
         public boolean containsAll(Collection coll) {
-            synchronized(mutex) {return c.containsAll(coll);}
+            synchronized (mutex) {return c.containsAll(coll);}
         }
         public boolean addAll(Collection coll) {
-            synchronized(mutex) {return c.addAll(coll);}
+            synchronized (mutex) {return c.addAll(coll);}
         }
         public boolean removeAll(Collection coll) {
-            synchronized(mutex) {return c.removeAll(coll);}
+            synchronized (mutex) {return c.removeAll(coll);}
         }
         public boolean retainAll(Collection coll) {
-            synchronized(mutex) {return c.retainAll(coll);}
+            synchronized (mutex) {return c.retainAll(coll);}
         }
         public void clear() {
-            synchronized(mutex) {c.clear();}
+            synchronized (mutex) {c.clear();}
         }
         public String toString() {
-            synchronized(mutex) {return c.toString();}
+            synchronized (mutex) {return c.toString();}
         }
         private void writeObject(ObjectOutputStream s) throws IOException {
-            synchronized(mutex) {s.defaultWriteObject();}
+            synchronized (mutex) {s.defaultWriteObject();}
         }
     }
 
@@ -1671,7 +1671,7 @@ public class Collections {
      * 
      *  Set s = Collections.synchronizedSet(new HashSet());
      *      ...
-     *  synchronized(s) {
+     *  synchronized (s) {
      *      Iterator i = s.iterator(); // Must be in the synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1709,10 +1709,10 @@ public class Collections {
         }
 
         public boolean equals(Object o) {
-            synchronized(mutex) {return c.equals(o);}
+            synchronized (mutex) {return c.equals(o);}
         }
         public int hashCode() {
-            synchronized(mutex) {return c.hashCode();}
+            synchronized (mutex) {return c.hashCode();}
         }
     }
 
@@ -1728,7 +1728,7 @@ public class Collections {
      * 
      *  SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
      *      ...
-     *  synchronized(s) {
+     *  synchronized (s) {
      *      Iterator i = s.iterator(); // Must be in the synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1739,7 +1739,7 @@ public class Collections {
      *  SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
      *  SortedSet s2 = s.headSet(foo);
      *      ...
-     *  synchronized(s) {  // Note: s, not s2!!!
+     *  synchronized (s) {  // Note: s, not s2!!!
      *      Iterator i = s2.iterator(); // Must be in the synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1766,7 +1766,7 @@ public class Collections {
     {
         private static final long serialVersionUID = 8695801310862127406L;
 
-        final private SortedSet ss;
+        private final SortedSet ss;
 
         SynchronizedSortedSet(SortedSet s) {
             super(s);
@@ -1778,31 +1778,31 @@ public class Collections {
         }
 
         public Comparator comparator() {
-            synchronized(mutex) {return ss.comparator();}
+            synchronized (mutex) {return ss.comparator();}
         }
 
         public SortedSet subSet(E fromElement, E toElement) {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedSortedSet(
                     ss.subSet(fromElement, toElement), mutex);
             }
         }
         public SortedSet headSet(E toElement) {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedSortedSet(ss.headSet(toElement), mutex);
             }
         }
         public SortedSet tailSet(E fromElement) {
-            synchronized(mutex) {
+            synchronized (mutex) {
                return new SynchronizedSortedSet(ss.tailSet(fromElement),mutex);
             }
         }
 
         public E first() {
-            synchronized(mutex) {return ss.first();}
+            synchronized (mutex) {return ss.first();}
         }
         public E last() {
-            synchronized(mutex) {return ss.last();}
+            synchronized (mutex) {return ss.last();}
         }
     }
 
@@ -1817,7 +1817,7 @@ public class Collections {
      * 
      *  List list = Collections.synchronizedList(new ArrayList());
      *      ...
-     *  synchronized(list) {
+     *  synchronized (list) {
      *      Iterator i = list.iterator(); // Must be in synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1863,34 +1863,34 @@ public class Collections {
         }
 
         public boolean equals(Object o) {
-            synchronized(mutex) {return list.equals(o);}
+            synchronized (mutex) {return list.equals(o);}
         }
         public int hashCode() {
-            synchronized(mutex) {return list.hashCode();}
+            synchronized (mutex) {return list.hashCode();}
         }
 
         public E get(int index) {
-            synchronized(mutex) {return list.get(index);}
+            synchronized (mutex) {return list.get(index);}
         }
         public E set(int index, E element) {
-            synchronized(mutex) {return list.set(index, element);}
+            synchronized (mutex) {return list.set(index, element);}
         }
         public void add(int index, E element) {
-            synchronized(mutex) {list.add(index, element);}
+            synchronized (mutex) {list.add(index, element);}
         }
         public E remove(int index) {
-            synchronized(mutex) {return list.remove(index);}
+            synchronized (mutex) {return list.remove(index);}
         }
 
         public int indexOf(Object o) {
-            synchronized(mutex) {return list.indexOf(o);}
+            synchronized (mutex) {return list.indexOf(o);}
         }
         public int lastIndexOf(Object o) {
-            synchronized(mutex) {return list.lastIndexOf(o);}
+            synchronized (mutex) {return list.lastIndexOf(o);}
         }
 
         public boolean addAll(int index, Collection c) {
-            synchronized(mutex) {return list.addAll(index, c);}
+            synchronized (mutex) {return list.addAll(index, c);}
         }
 
         public ListIterator listIterator() {
@@ -1902,7 +1902,7 @@ public class Collections {
         }
 
         public List subList(int fromIndex, int toIndex) {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedList(list.subList(fromIndex, toIndex),
                                             mutex);
             }
@@ -1943,7 +1943,7 @@ public class Collections {
         }
 
         public List subList(int fromIndex, int toIndex) {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedRandomAccessList(
                     list.subList(fromIndex, toIndex), mutex);
             }
@@ -1975,7 +1975,7 @@ public class Collections {
      *      ...
      *  Set s = m.keySet();  // Needn't be in synchronized block
      *      ...
-     *  synchronized(m) {  // Synchronizing on m, not s!
+     *  synchronized (m) {  // Synchronizing on m, not s!
      *      Iterator i = s.iterator(); // Must be in synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -2016,32 +2016,32 @@ public class Collections {
         }
 
         public int size() {
-            synchronized(mutex) {return m.size();}
+            synchronized (mutex) {return m.size();}
         }
         public boolean isEmpty() {
-            synchronized(mutex) {return m.isEmpty();}
+            synchronized (mutex) {return m.isEmpty();}
         }
         public boolean containsKey(Object key) {
-            synchronized(mutex) {return m.containsKey(key);}
+            synchronized (mutex) {return m.containsKey(key);}
         }
         public boolean containsValue(Object value) {
-            synchronized(mutex) {return m.containsValue(value);}
+            synchronized (mutex) {return m.containsValue(value);}
         }
         public V get(Object key) {
-            synchronized(mutex) {return m.get(key);}
+            synchronized (mutex) {return m.get(key);}
         }
 
         public V put(K key, V value) {
-            synchronized(mutex) {return m.put(key, value);}
+            synchronized (mutex) {return m.put(key, value);}
         }
         public V remove(Object key) {
-            synchronized(mutex) {return m.remove(key);}
+            synchronized (mutex) {return m.remove(key);}
         }
         public void putAll(Map map) {
-            synchronized(mutex) {m.putAll(map);}
+            synchronized (mutex) {m.putAll(map);}
         }
         public void clear() {
-            synchronized(mutex) {m.clear();}
+            synchronized (mutex) {m.clear();}
         }
 
         private transient Set keySet = null;
@@ -2049,7 +2049,7 @@ public class Collections {
         private transient Collection values = null;
 
         public Set keySet() {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 if (keySet==null)
                     keySet = new SynchronizedSet(m.keySet(), mutex);
                 return keySet;
@@ -2057,7 +2057,7 @@ public class Collections {
         }
 
         public Set> entrySet() {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 if (entrySet==null)
                     entrySet = new SynchronizedSet>(m.entrySet(), mutex);
                 return entrySet;
@@ -2065,7 +2065,7 @@ public class Collections {
         }
 
         public Collection values() {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 if (values==null)
                     values = new SynchronizedCollection(m.values(), mutex);
                 return values;
@@ -2073,16 +2073,16 @@ public class Collections {
         }
 
         public boolean equals(Object o) {
-            synchronized(mutex) {return m.equals(o);}
+            synchronized (mutex) {return m.equals(o);}
         }
         public int hashCode() {
-            synchronized(mutex) {return m.hashCode();}
+            synchronized (mutex) {return m.hashCode();}
         }
         public String toString() {
-            synchronized(mutex) {return m.toString();}
+            synchronized (mutex) {return m.toString();}
         }
         private void writeObject(ObjectOutputStream s) throws IOException {
-            synchronized(mutex) {s.defaultWriteObject();}
+            synchronized (mutex) {s.defaultWriteObject();}
         }
     }
 
@@ -2101,7 +2101,7 @@ public class Collections {
      *      ...
      *  Set s = m.keySet();  // Needn't be in synchronized block
      *      ...
-     *  synchronized(m) {  // Synchronizing on m, not s!
+     *  synchronized (m) {  // Synchronizing on m, not s!
      *      Iterator i = s.iterator(); // Must be in synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -2114,7 +2114,7 @@ public class Collections {
      *      ...
      *  Set s2 = m2.keySet();  // Needn't be in synchronized block
      *      ...
-     *  synchronized(m) {  // Synchronizing on m, not m2 or s2!
+     *  synchronized (m) {  // Synchronizing on m, not m2 or s2!
      *      Iterator i = s.iterator(); // Must be in synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -2154,31 +2154,31 @@ public class Collections {
         }
 
         public Comparator comparator() {
-            synchronized(mutex) {return sm.comparator();}
+            synchronized (mutex) {return sm.comparator();}
         }
 
         public SortedMap subMap(K fromKey, K toKey) {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedSortedMap(
                     sm.subMap(fromKey, toKey), mutex);
             }
         }
         public SortedMap headMap(K toKey) {
-            synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedSortedMap(sm.headMap(toKey), mutex);
             }
         }
         public SortedMap tailMap(K fromKey) {
-            synchronized(mutex) {
+            synchronized (mutex) {
                return new SynchronizedSortedMap(sm.tailMap(fromKey),mutex);
             }
         }
 
         public K firstKey() {
-            synchronized(mutex) {return sm.firstKey();}
+            synchronized (mutex) {return sm.firstKey();}
         }
         public K lastKey() {
-            synchronized(mutex) {return sm.lastKey();}
+            synchronized (mutex) {return sm.lastKey();}
         }
     }
 
@@ -3317,7 +3317,7 @@ public class Collections {
     {
         private static final long serialVersionUID = 3193687207550431679L;
 
-        final private E element;
+        private final E element;
 
         SingletonSet(E e) {element = e;}
 
@@ -3448,7 +3448,7 @@ public class Collections {
      * @param  o the element to appear repeatedly in the returned list.
      * @return an immutable list consisting of n copies of the
      *         specified object.
-     * @throws IllegalArgumentException if n < 0.
+     * @throws IllegalArgumentException if {@code n < 0}
      * @see    List#addAll(Collection)
      * @see    List#addAll(int, Collection)
      */
diff --git a/src/share/classes/java/util/ComparableTimSort.java b/src/share/classes/java/util/ComparableTimSort.java
index 4907a0f5bcd0935d3aeebaf9bda10bccf9450597..f78ee9a2efc711bf0e1dde89eed9a5fe38976548 100644
--- a/src/share/classes/java/util/ComparableTimSort.java
+++ b/src/share/classes/java/util/ComparableTimSort.java
@@ -207,7 +207,7 @@ class ComparableTimSort {
      * @param lo the index of the first element in the range to be sorted
      * @param hi the index after the last element in the range to be sorted
      * @param start the index of the first element in the range that is
-     *        not already known to be sorted (@code lo <= start <= hi}
+     *        not already known to be sorted ({@code lo <= start <= hi})
      */
     @SuppressWarnings("fallthrough")
     private static void binarySort(Object[] a, int lo, int hi, int start) {
@@ -245,7 +245,7 @@ class ComparableTimSort {
              */
             int n = start - left;  // The number of elements to move
             // Switch is just an optimization for arraycopy in default case
-            switch(n) {
+            switch (n) {
                 case 2:  a[left + 2] = a[left + 1];
                 case 1:  a[left + 1] = a[left];
                          break;
@@ -275,7 +275,7 @@ class ComparableTimSort {
      * @param a the array in which a run is to be counted and possibly reversed
      * @param lo index of the first element in the run
      * @param hi index after the last element that may be contained in the run.
-              It is required that @code{lo < hi}.
+              It is required that {@code lo < hi}.
      * @return  the length of the run beginning at the specified position in
      *          the specified array
      */
@@ -288,7 +288,7 @@ class ComparableTimSort {
 
         // Find end of run, and reverse range if descending
         if (((Comparable) a[runHi++]).compareTo(a[lo]) < 0) { // Descending
-            while(runHi < hi && ((Comparable) a[runHi]).compareTo(a[runHi - 1]) < 0)
+            while (runHi < hi && ((Comparable) a[runHi]).compareTo(a[runHi - 1]) < 0)
                 runHi++;
             reverseRange(a, lo, runHi);
         } else {                              // Ascending
diff --git a/src/share/classes/java/util/Random.java b/src/share/classes/java/util/Random.java
index 833cfbbe256cf0eb68b35ecee4abed0160147497..8f217833bfe260e3053fb3c5ad6437bda97f50f9 100644
--- a/src/share/classes/java/util/Random.java
+++ b/src/share/classes/java/util/Random.java
@@ -77,9 +77,9 @@ class Random implements java.io.Serializable {
      */
     private final AtomicLong seed;
 
-    private final static long multiplier = 0x5DEECE66DL;
-    private final static long addend = 0xBL;
-    private final static long mask = (1L << 48) - 1;
+    private static final long multiplier = 0x5DEECE66DL;
+    private static final long addend = 0xBL;
+    private static final long mask = (1L << 48) - 1;
 
     /**
      * Creates a new random number generator. This constructor sets
@@ -285,7 +285,7 @@ class Random implements java.io.Serializable {
      * @return the next pseudorandom, uniformly distributed {@code int}
      *         value between {@code 0} (inclusive) and {@code n} (exclusive)
      *         from this random number generator's sequence
-     * @exception IllegalArgumentException if n is not positive
+     * @throws IllegalArgumentException if n is not positive
      * @since 1.2
      */
 
diff --git a/src/share/classes/java/util/Stack.java b/src/share/classes/java/util/Stack.java
index 9c17b31a75bc145ab266c5ed4cfa4043f549735d..8dd2ebddbbe3df2d85cbca86fec1f876c1e41177 100644
--- a/src/share/classes/java/util/Stack.java
+++ b/src/share/classes/java/util/Stack.java
@@ -73,9 +73,9 @@ class Stack extends Vector {
      * Removes the object at the top of this stack and returns that
      * object as the value of this function.
      *
-     * @return     The object at the top of this stack (the last item
-     *             of the Vector object).
-     * @exception  EmptyStackException  if this stack is empty.
+     * @return  The object at the top of this stack (the last item
+     *          of the Vector object).
+     * @throws  EmptyStackException  if this stack is empty.
      */
     public synchronized E pop() {
         E       obj;
@@ -91,9 +91,9 @@ class Stack extends Vector {
      * Looks at the object at the top of this stack without removing it
      * from the stack.
      *
-     * @return     the object at the top of this stack (the last item
-     *             of the Vector object).
-     * @exception  EmptyStackException  if this stack is empty.
+     * @return  the object at the top of this stack (the last item
+     *          of the Vector object).
+     * @throws  EmptyStackException  if this stack is empty.
      */
     public synchronized E peek() {
         int     len = size();
diff --git a/src/share/classes/java/util/TimSort.java b/src/share/classes/java/util/TimSort.java
index 6940883d02a98a0a68513da9b8e7245a03ff1ae8..6d4727ac4e7a574aeb7df1f786357f3c3e5d55ca 100644
--- a/src/share/classes/java/util/TimSort.java
+++ b/src/share/classes/java/util/TimSort.java
@@ -239,7 +239,7 @@ class TimSort {
      * @param lo the index of the first element in the range to be sorted
      * @param hi the index after the last element in the range to be sorted
      * @param start the index of the first element in the range that is
-     *        not already known to be sorted (@code lo <= start <= hi}
+     *        not already known to be sorted ({@code lo <= start <= hi})
      * @param c comparator to used for the sort
      */
     @SuppressWarnings("fallthrough")
@@ -278,7 +278,7 @@ class TimSort {
              */
             int n = start - left;  // The number of elements to move
             // Switch is just an optimization for arraycopy in default case
-            switch(n) {
+            switch (n) {
                 case 2:  a[left + 2] = a[left + 1];
                 case 1:  a[left + 1] = a[left];
                          break;
@@ -308,7 +308,7 @@ class TimSort {
      * @param a the array in which a run is to be counted and possibly reversed
      * @param lo index of the first element in the run
      * @param hi index after the last element that may be contained in the run.
-              It is required that @code{lo < hi}.
+              It is required that {@code lo < hi}.
      * @param c the comparator to used for the sort
      * @return  the length of the run beginning at the specified position in
      *          the specified array
@@ -322,7 +322,7 @@ class TimSort {
 
         // Find end of run, and reverse range if descending
         if (c.compare(a[runHi++], a[lo]) < 0) { // Descending
-            while(runHi < hi && c.compare(a[runHi], a[runHi - 1]) < 0)
+            while (runHi < hi && c.compare(a[runHi], a[runHi - 1]) < 0)
                 runHi++;
             reverseRange(a, lo, runHi);
         } else {                              // Ascending
diff --git a/src/share/classes/java/util/TreeMap.java b/src/share/classes/java/util/TreeMap.java
index b0c9aa7d67a781c473e38c1576bbcaf8b8962eb6..8c055d8ce98607a965c26e781dc6a8c224c06f07 100644
--- a/src/share/classes/java/util/TreeMap.java
+++ b/src/share/classes/java/util/TreeMap.java
@@ -1056,11 +1056,11 @@ public class TreeMap
         public Comparator comparator() { return m.comparator(); }
         public E pollFirst() {
             Map.Entry e = m.pollFirstEntry();
-            return e == null? null : e.getKey();
+            return (e == null) ? null : e.getKey();
         }
         public E pollLast() {
             Map.Entry e = m.pollLastEntry();
-            return e == null? null : e.getKey();
+            return (e == null) ? null : e.getKey();
         }
         public boolean remove(Object o) {
             int oldSize = size();
@@ -1196,7 +1196,7 @@ public class TreeMap
      * Test two values for equality.  Differs from o1.equals(o2) only in
      * that it copes with {@code null} o1 properly.
      */
-    final static boolean valEquals(Object o1, Object o2) {
+    static final boolean valEquals(Object o1, Object o2) {
         return (o1==null ? o2==null : o1.equals(o2));
     }
 
@@ -1204,7 +1204,7 @@ public class TreeMap
      * Return SimpleImmutableEntry for entry, or null if null
      */
     static  Map.Entry exportEntry(TreeMap.Entry e) {
-        return e == null? null :
+        return (e == null) ? null :
             new AbstractMap.SimpleImmutableEntry(e);
     }
 
@@ -1212,7 +1212,7 @@ public class TreeMap
      * Return key for entry, or null if null
      */
     static  K keyOrNull(TreeMap.Entry e) {
-        return e == null? null : e.key;
+        return (e == null) ? null : e.key;
     }
 
     /**
@@ -1237,7 +1237,7 @@ public class TreeMap
     /**
      * @serial include
      */
-    static abstract class NavigableSubMap extends AbstractMap
+    abstract static class NavigableSubMap extends AbstractMap
         implements NavigableMap, java.io.Serializable {
         /**
          * The backing map.
@@ -1412,11 +1412,11 @@ public class TreeMap
         }
 
         public final V get(Object key) {
-            return !inRange(key)? null :  m.get(key);
+            return !inRange(key) ? null :  m.get(key);
         }
 
         public final V remove(Object key) {
-            return !inRange(key)? null  : m.remove(key);
+            return !inRange(key) ? null : m.remove(key);
         }
 
         public final Map.Entry ceilingEntry(K key) {
@@ -1559,7 +1559,8 @@ public class TreeMap
                 if (!inRange(key))
                     return false;
                 TreeMap.Entry node = m.getEntry(key);
-                if (node!=null && valEquals(node.getValue(),entry.getValue())){
+                if (node!=null && valEquals(node.getValue(),
+                                            entry.getValue())) {
                     m.deleteEntry(node);
                     return true;
                 }
@@ -1724,7 +1725,7 @@ public class TreeMap
                                        false,     toKey, inclusive);
         }
 
-        public NavigableMap tailMap(K fromKey, boolean inclusive){
+        public NavigableMap tailMap(K fromKey, boolean inclusive) {
             if (!inRange(fromKey, inclusive))
                 throw new IllegalArgumentException("fromKey out of range");
             return new AscendingSubMap(m,
@@ -1805,7 +1806,7 @@ public class TreeMap
                                         toEnd, hi,    hiInclusive);
         }
 
-        public NavigableMap tailMap(K fromKey, boolean inclusive){
+        public NavigableMap tailMap(K fromKey, boolean inclusive) {
             if (!inRange(fromKey, inclusive))
                 throw new IllegalArgumentException("fromKey out of range");
             return new DescendingSubMap(m,
@@ -2143,7 +2144,7 @@ public class TreeMap
         // If strictly internal, copy successor's element to p and then make p
         // point to successor.
         if (p.left != null && p.right != null) {
-            Entry s = successor (p);
+            Entry s = successor(p);
             p.key = s.key;
             p.value = s.value;
             p = s;
diff --git a/src/share/classes/java/util/TreeSet.java b/src/share/classes/java/util/TreeSet.java
index 99e3f313ad681213e99e19ca050270d14c2b04c0..c2e2bdf8ffd1af21c38eae27960b019da2a363fd 100644
--- a/src/share/classes/java/util/TreeSet.java
+++ b/src/share/classes/java/util/TreeSet.java
@@ -452,7 +452,7 @@ public class TreeSet extends AbstractSet
      */
     public E pollFirst() {
         Map.Entry e = m.pollFirstEntry();
-        return (e == null)? null : e.getKey();
+        return (e == null) ? null : e.getKey();
     }
 
     /**
@@ -460,7 +460,7 @@ public class TreeSet extends AbstractSet
      */
     public E pollLast() {
         Map.Entry e = m.pollLastEntry();
-        return (e == null)? null : e.getKey();
+        return (e == null) ? null : e.getKey();
     }
 
     /**
diff --git a/src/share/classes/java/util/Vector.java b/src/share/classes/java/util/Vector.java
index e508aa5b5c00180054275766c9d6ff64044ae5fc..f1a9c172a278cd3ad40ee06ea4dc6e8e06361ed6 100644
--- a/src/share/classes/java/util/Vector.java
+++ b/src/share/classes/java/util/Vector.java
@@ -919,7 +919,7 @@ public class Vector
      *         elements (optional), or if the specified collection is null
      * @since 1.2
      */
-    public synchronized boolean retainAll(Collection c)  {
+    public synchronized boolean retainAll(Collection c) {
         return super.retainAll(c);
     }
 
diff --git a/src/share/classes/java/util/concurrent/AbstractExecutorService.java b/src/share/classes/java/util/concurrent/AbstractExecutorService.java
index 3a43617b0be61f44b6156910b90f7863b79d9e14..0322289e52e6f069e42c12bc57fe0331215c2173 100644
--- a/src/share/classes/java/util/concurrent/AbstractExecutorService.java
+++ b/src/share/classes/java/util/concurrent/AbstractExecutorService.java
@@ -51,20 +51,20 @@ import java.util.*;
  * 

Extension example. Here is a sketch of a class * that customizes {@link ThreadPoolExecutor} to use * a CustomTask class instead of the default FutureTask: - *

+ *  
 {@code
  * public class CustomThreadPoolExecutor extends ThreadPoolExecutor {
  *
- *   static class CustomTask<V> implements RunnableFuture<V> {...}
+ *   static class CustomTask implements RunnableFuture {...}
  *
- *   protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) {
- *       return new CustomTask<V>(c);
+ *   protected  RunnableFuture newTaskFor(Callable c) {
+ *       return new CustomTask(c);
  *   }
- *   protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) {
- *       return new CustomTask<V>(r, v);
+ *   protected  RunnableFuture newTaskFor(Runnable r, V v) {
+ *       return new CustomTask(r, v);
  *   }
  *   // ... add constructors, etc.
- * }
- * 
+ * }}
+ * * @since 1.5 * @author Doug Lea */ @@ -106,7 +106,7 @@ public abstract class AbstractExecutorService implements ExecutorService { */ public Future submit(Runnable task) { if (task == null) throw new NullPointerException(); - RunnableFuture ftask = newTaskFor(task, null); + RunnableFuture ftask = newTaskFor(task, null); execute(ftask); return ftask; } @@ -158,7 +158,7 @@ public abstract class AbstractExecutorService implements ExecutorService { // Record exceptions so that if we fail to obtain any // result, we can throw the last exception we got. ExecutionException ee = null; - long lastTime = (timed)? System.nanoTime() : 0; + long lastTime = timed ? System.nanoTime() : 0; Iterator> it = tasks.iterator(); // Start one task for sure; the rest incrementally @@ -191,8 +191,6 @@ public abstract class AbstractExecutorService implements ExecutorService { --active; try { return f.get(); - } catch (InterruptedException ie) { - throw ie; } catch (ExecutionException eex) { ee = eex; } catch (RuntimeException rex) { diff --git a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java index 7fb9b07c872bd3f0b66ffb7a7bc9239f660aef32..8074669654c5a0b9de2cbcce2524374a8bac6382 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -1270,7 +1270,7 @@ public class ConcurrentHashMap extends AbstractMap * 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 IOException { s.defaultWriteObject(); for (int k = 0; k < segments.length; ++k) { @@ -1298,7 +1298,7 @@ public class ConcurrentHashMap extends AbstractMap * @param s the stream */ private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException { + throws IOException, ClassNotFoundException { s.defaultReadObject(); // Initialize each segment to be minimally sized, and let grow. diff --git a/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java b/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java index 4837661a4416028e8a3e5a12a98150b8f1229be0..72133fedad7691db6cd64c944b17251fe3156bb0 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java +++ b/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java @@ -38,7 +38,6 @@ package java.util.concurrent; import java.util.AbstractCollection; import java.util.ArrayList; import java.util.Collection; -import java.util.ConcurrentModificationException; import java.util.Deque; import java.util.Iterator; import java.util.NoSuchElementException; @@ -212,7 +211,7 @@ public class ConcurrentLinkedDeque * The actual representation we use is that p.next == p means to * goto the first node (which in turn is reached by following prev * pointers from head), and p.next == null && p.prev == p means - * that the iteration is at an end and that p is a (final static) + * that the iteration is at an end and that p is a (static final) * dummy node, NEXT_TERMINATOR, and not the last active node. * Finishing the iteration when encountering such a TERMINATOR is * good enough for read-only traversals, so such traversals can use @@ -271,7 +270,7 @@ public class ConcurrentLinkedDeque */ private transient volatile Node tail; - private final static Node PREV_TERMINATOR, NEXT_TERMINATOR; + private static final Node PREV_TERMINATOR, NEXT_TERMINATOR; static { PREV_TERMINATOR = new Node(null); @@ -401,7 +400,7 @@ public class ConcurrentLinkedDeque } } - private final static int HOPS = 2; + private static final int HOPS = 2; /** * Unlinks non-null node x. @@ -871,7 +870,7 @@ public class ConcurrentLinkedDeque /** * Inserts the specified element at the front of this deque. * - * @throws NullPointerException {@inheritDoc} + * @throws NullPointerException if the specified element is null */ public void addFirst(E e) { linkFirst(e); @@ -882,7 +881,7 @@ public class ConcurrentLinkedDeque * *

This method is equivalent to {@link #add}. * - * @throws NullPointerException {@inheritDoc} + * @throws NullPointerException if the specified element is null */ public void addLast(E e) { linkLast(e); @@ -892,7 +891,7 @@ public class ConcurrentLinkedDeque * Inserts the specified element at the front of this deque. * * @return {@code true} always - * @throws NullPointerException {@inheritDoc} + * @throws NullPointerException if the specified element is null */ public boolean offerFirst(E e) { linkFirst(e); @@ -905,7 +904,7 @@ public class ConcurrentLinkedDeque *

This method is equivalent to {@link #add}. * * @return {@code true} always - * @throws NullPointerException {@inheritDoc} + * @throws NullPointerException if the specified element is null */ public boolean offerLast(E e) { linkLast(e); @@ -940,7 +939,7 @@ public class ConcurrentLinkedDeque /** * @throws NoSuchElementException {@inheritDoc} */ - public E getLast() { + public E getLast() { return screenNullResult(peekLast()); } @@ -1016,7 +1015,7 @@ public class ConcurrentLinkedDeque * * @param o element to be removed from this deque, if present * @return {@code true} if the deque contained the specified element - * @throws NullPointerException if the specified element is {@code null} + * @throws NullPointerException if the specified element is null */ public boolean removeFirstOccurrence(Object o) { checkNotNull(o); @@ -1037,7 +1036,7 @@ public class ConcurrentLinkedDeque * * @param o element to be removed from this deque, if present * @return {@code true} if the deque contained the specified element - * @throws NullPointerException if the specified element is {@code null} + * @throws NullPointerException if the specified element is null */ public boolean removeLastOccurrence(Object o) { checkNotNull(o); @@ -1110,7 +1109,7 @@ public class ConcurrentLinkedDeque * * @param o element to be removed from this deque, if present * @return {@code true} if the deque contained the specified element - * @throws NullPointerException if the specified element is {@code null} + * @throws NullPointerException if the specified element is null */ public boolean remove(Object o) { return removeFirstOccurrence(o); @@ -1165,7 +1164,7 @@ public class ConcurrentLinkedDeque beginningOfTheEnd.lazySetPrev(p); // CAS piggyback if (p.casNext(null, beginningOfTheEnd)) { // Successful CAS is the linearization point - // for all elements to be added to this queue. + // for all elements to be added to this deque. if (!casTail(t, last)) { // Try a little harder to update tail, // since we may be adding many elements. @@ -1251,12 +1250,12 @@ public class ConcurrentLinkedDeque * 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). * - *

The returned {@code Iterator} is a "weakly consistent" iterator that + *

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. + * 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. * * @return an iterator over the elements in this deque in proper sequence */ @@ -1269,12 +1268,12 @@ public class ConcurrentLinkedDeque * sequential order. The elements will be returned in order from * last (tail) to first (head). * - *

The returned {@code Iterator} is a "weakly consistent" iterator that + *

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. + * 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. * * @return an iterator over the elements in this deque in reverse order */ diff --git a/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java index 0d6381cd971e7c632f914a6aed936dee63a2fd36..6ff1b8a5119b9b25c837f4856424647ed95c9a83 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java +++ b/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java @@ -65,8 +65,8 @@ import java.util.Queue; *

Iterators are weakly consistent, returning elements * reflecting the state of the queue at some point at or since the * creation of the iterator. They do not throw {@link - * ConcurrentModificationException}, and may proceed concurrently with - * other operations. Elements contained in the queue since the creation + * java.util.ConcurrentModificationException}, and may proceed concurrently + * with other operations. Elements contained in the queue since the creation * of the iterator will be returned exactly once. * *

Beware that, unlike in most collections, the {@code size} method @@ -634,12 +634,12 @@ public class ConcurrentLinkedQueue extends AbstractQueue * 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). * - *

The returned {@code Iterator} is a "weakly consistent" iterator that + *

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. + * 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. * * @return an iterator over the elements in this queue in proper sequence */ diff --git a/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java b/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java index d129564acebe71c2d82577f6511e76c11ee0624c..09f8dc6f5b2309bfb10f62bbc2c9bc5c829dd7e6 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java +++ b/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java @@ -362,12 +362,12 @@ public class ConcurrentSkipListSet public E pollFirst() { Map.Entry e = m.pollFirstEntry(); - return e == null? null : e.getKey(); + return (e == null) ? null : e.getKey(); } public E pollLast() { Map.Entry e = m.pollLastEntry(); - return e == null? null : e.getKey(); + return (e == null) ? null : e.getKey(); } diff --git a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java index 97d27cbe6a43143f393265cc04cbfb5b51011845..73b9df32269d23cdd41e5c7b369a3bd43e05a4ea 100644 --- a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java +++ b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java @@ -547,7 +547,7 @@ public class CopyOnWriteArrayList * @param fromIndex index of first element to be removed * @param toIndex index after last element to be removed * @throws IndexOutOfBoundsException if fromIndex or toIndex out of range - * (@code{fromIndex < 0 || toIndex > size() || toIndex < fromIndex}) + * ({@code{fromIndex < 0 || toIndex > size() || toIndex < fromIndex}) */ private void removeRange(int fromIndex, int toIndex) { final ReentrantLock lock = this.lock; @@ -989,7 +989,7 @@ public class CopyOnWriteArrayList } private static class COWIterator implements ListIterator { - /** Snapshot of the array **/ + /** Snapshot of the array */ private final Object[] snapshot; /** Index of element to be returned by subsequent call to next. */ private int cursor; diff --git a/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java b/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java index 9114d45fb9a054eedb603198783367b5583780d8..1d2de1d85c9073d564470fd896cb62b24711a332 100644 --- a/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java +++ b/src/share/classes/java/util/concurrent/CopyOnWriteArraySet.java @@ -59,24 +59,23 @@ import java.util.*; * copy-on-write set to maintain a set of Handler objects that * perform some action upon state updates. * - *

+ *  
 {@code
  * class Handler { void handle(); ... }
  *
  * class X {
- *    private final CopyOnWriteArraySet<Handler> handlers
- *       = new CopyOnWriteArraySet<Handler>();
- *    public void addHandler(Handler h) { handlers.add(h); }
+ *   private final CopyOnWriteArraySet handlers
+ *     = new CopyOnWriteArraySet();
+ *   public void addHandler(Handler h) { handlers.add(h); }
  *
- *    private long internalState;
- *    private synchronized void changeState() { internalState = ...; }
+ *   private long internalState;
+ *   private synchronized void changeState() { internalState = ...; }
  *
- *    public void update() {
- *       changeState();
- *       for (Handler handler : handlers)
- *          handler.handle();
- *    }
- * }
- * 
+ * public void update() { + * changeState(); + * for (Handler handler : handlers) + * handler.handle(); + * } + * }}
* *

This class is a member of the * diff --git a/src/share/classes/java/util/concurrent/CountDownLatch.java b/src/share/classes/java/util/concurrent/CountDownLatch.java index ec39cea44d83d78626c9500cb3feb28298bb835a..1c8a0253c149a137a913aa74dfe060bb11b9424b 100644 --- a/src/share/classes/java/util/concurrent/CountDownLatch.java +++ b/src/share/classes/java/util/concurrent/CountDownLatch.java @@ -175,7 +175,7 @@ public class CountDownLatch { } protected int tryAcquireShared(int acquires) { - return getState() == 0? 1 : -1; + return (getState() == 0) ? 1 : -1; } protected boolean tryReleaseShared(int releases) { diff --git a/src/share/classes/java/util/concurrent/DelayQueue.java b/src/share/classes/java/util/concurrent/DelayQueue.java index 6ce3471b18c2bb5569a181b21f57bbdf0147af33..ecb9eefc6e26be12cf3b65e0d19cb061a311df7c 100644 --- a/src/share/classes/java/util/concurrent/DelayQueue.java +++ b/src/share/classes/java/util/concurrent/DelayQueue.java @@ -482,12 +482,14 @@ public class DelayQueue extends AbstractQueue /** * Returns an iterator over all the elements (both expired and * unexpired) in this queue. The iterator does not return the - * elements in any particular order. The returned - * 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. + * elements in any particular order. + * + *

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. * * @return an iterator over the elements in this queue */ diff --git a/src/share/classes/java/util/concurrent/Exchanger.java b/src/share/classes/java/util/concurrent/Exchanger.java index c4563a8ae9b695c10eac43e63bcf1fceb1dcaaa8..8648278b75566f5363986e84551a16a8c1acff8b 100644 --- a/src/share/classes/java/util/concurrent/Exchanger.java +++ b/src/share/classes/java/util/concurrent/Exchanger.java @@ -355,7 +355,9 @@ public class Exchanger { else if (y == null && // Try to occupy slot.compareAndSet(null, me)) { if (index == 0) // Blocking wait for slot 0 - return timed? awaitNanos(me, slot, nanos): await(me, slot); + return timed ? + awaitNanos(me, slot, nanos) : + await(me, slot); Object v = spinWait(me, slot); // Spin wait for non-0 if (v != CANCEL) return v; @@ -597,8 +599,8 @@ public class Exchanger { * dormant until one of two things happens: *

*

If the current thread: *

    @@ -616,7 +618,7 @@ public class Exchanger { */ public V exchange(V x) throws InterruptedException { if (!Thread.interrupted()) { - Object v = doExchange(x == null? NULL_ITEM : x, false, 0); + Object v = doExchange((x == null) ? NULL_ITEM : x, false, 0); if (v == NULL_ITEM) return null; if (v != CANCEL) @@ -671,7 +673,7 @@ public class Exchanger { public V exchange(V x, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { if (!Thread.interrupted()) { - Object v = doExchange(x == null? NULL_ITEM : x, + Object v = doExchange((x == null) ? NULL_ITEM : x, true, unit.toNanos(timeout)); if (v == NULL_ITEM) return null; diff --git a/src/share/classes/java/util/concurrent/Executor.java b/src/share/classes/java/util/concurrent/Executor.java index 85b3277f43d57e38ca1668422c7253cf31289697..5e67fbcdd08fe60aa75f4281d7fc8b2f4b42796d 100644 --- a/src/share/classes/java/util/concurrent/Executor.java +++ b/src/share/classes/java/util/concurrent/Executor.java @@ -79,37 +79,37 @@ package java.util.concurrent; * serializes the submission of tasks to a second executor, * illustrating a composite executor. * - *
    + *  
     {@code
      * class SerialExecutor implements Executor {
    - *     final Queue<Runnable> tasks = new ArrayDeque<Runnable>();
    - *     final Executor executor;
    - *     Runnable active;
    - *
    - *     SerialExecutor(Executor executor) {
    - *         this.executor = executor;
    - *     }
    - *
    - *     public synchronized void execute(final Runnable r) {
    - *         tasks.offer(new Runnable() {
    - *             public void run() {
    - *                 try {
    - *                     r.run();
    - *                 } finally {
    - *                     scheduleNext();
    - *                 }
    - *             }
    - *         });
    - *         if (active == null) {
    - *             scheduleNext();
    + *   final Queue tasks = new ArrayDeque();
    + *   final Executor executor;
    + *   Runnable active;
    + *
    + *   SerialExecutor(Executor executor) {
    + *     this.executor = executor;
    + *   }
    + *
    + *   public synchronized void execute(final Runnable r) {
    + *     tasks.offer(new Runnable() {
    + *       public void run() {
    + *         try {
    + *           r.run();
    + *         } finally {
    + *           scheduleNext();
      *         }
    + *       }
    + *     });
    + *     if (active == null) {
    + *       scheduleNext();
      *     }
    + *   }
      *
    - *     protected synchronized void scheduleNext() {
    - *         if ((active = tasks.poll()) != null) {
    - *             executor.execute(active);
    - *         }
    + *   protected synchronized void scheduleNext() {
    + *     if ((active = tasks.poll()) != null) {
    + *       executor.execute(active);
      *     }
    - * }
    + * } + * }}
    * * The Executor implementations provided in this package * implement {@link ExecutorService}, which is a more extensive diff --git a/src/share/classes/java/util/concurrent/ExecutorCompletionService.java b/src/share/classes/java/util/concurrent/ExecutorCompletionService.java index 4d37c999018f6bf4b1ab469498cac82e68c0fff9..9908a8cfcdd2e45098a7692ebfe92247406d54a0 100644 --- a/src/share/classes/java/util/concurrent/ExecutorCompletionService.java +++ b/src/share/classes/java/util/concurrent/ExecutorCompletionService.java @@ -197,7 +197,8 @@ public class ExecutorCompletionService implements CompletionService { return completionQueue.poll(); } - public Future poll(long timeout, TimeUnit unit) throws InterruptedException { + public Future poll(long timeout, TimeUnit unit) + throws InterruptedException { return completionQueue.poll(timeout, unit); } diff --git a/src/share/classes/java/util/concurrent/Executors.java b/src/share/classes/java/util/concurrent/Executors.java index efa2f78f86f34533a0b154370bbabb2284f31586..75a490086ae6c828c3dc83dbc7ab475c33f66803 100644 --- a/src/share/classes/java/util/concurrent/Executors.java +++ b/src/share/classes/java/util/concurrent/Executors.java @@ -83,7 +83,7 @@ public class Executors { * * @param nThreads the number of threads in the pool * @return the newly created thread pool - * @throws IllegalArgumentException if nThreads <= 0 + * @throws IllegalArgumentException if {@code nThreads <= 0} */ public static ExecutorService newFixedThreadPool(int nThreads) { return new ThreadPoolExecutor(nThreads, nThreads, @@ -108,7 +108,7 @@ public class Executors { * @param threadFactory the factory to use when creating new threads * @return the newly created thread pool * @throws NullPointerException if threadFactory is null - * @throws IllegalArgumentException if nThreads <= 0 + * @throws IllegalArgumentException if {@code nThreads <= 0} */ public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) { return new ThreadPoolExecutor(nThreads, nThreads, @@ -242,7 +242,7 @@ public class Executors { * @param corePoolSize the number of threads to keep in the pool, * even if they are idle. * @return a newly created scheduled thread pool - * @throws IllegalArgumentException if corePoolSize < 0 + * @throws IllegalArgumentException if {@code corePoolSize < 0} */ public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) { return new ScheduledThreadPoolExecutor(corePoolSize); @@ -256,7 +256,7 @@ public class Executors { * @param threadFactory the factory to use when the executor * creates a new thread. * @return a newly created scheduled thread pool - * @throws IllegalArgumentException if corePoolSize < 0 + * @throws IllegalArgumentException if {@code corePoolSize < 0} * @throws NullPointerException if threadFactory is null */ public static ScheduledExecutorService newScheduledThreadPool( @@ -562,8 +562,8 @@ public class Executors { DefaultThreadFactory() { SecurityManager s = System.getSecurityManager(); - group = (s != null)? s.getThreadGroup() : - Thread.currentThread().getThreadGroup(); + group = (s != null) ? s.getThreadGroup() : + Thread.currentThread().getThreadGroup(); namePrefix = "pool-" + poolNumber.getAndIncrement() + "-thread-"; @@ -669,7 +669,7 @@ public class Executors { FinalizableDelegatedExecutorService(ExecutorService executor) { super(executor); } - protected void finalize() { + protected void finalize() { super.shutdown(); } } diff --git a/src/share/classes/java/util/concurrent/Future.java b/src/share/classes/java/util/concurrent/Future.java index 9d3d1ff741b72dd6153c95da0b47c01071c96f94..4abd3f4e1741ad577f05f56f0c6f3f64cacf5d31 100644 --- a/src/share/classes/java/util/concurrent/Future.java +++ b/src/share/classes/java/util/concurrent/Future.java @@ -47,21 +47,21 @@ package java.util.concurrent; * computation has completed, the computation cannot be cancelled. * If you would like to use a Future for the sake * of cancellability but not provide a usable result, you can - * declare types of the form Future<?> and + * declare types of the form {@code Future} and * return null as a result of the underlying task. * *

    * Sample Usage (Note that the following classes are all * made-up.)

    - *

    + *  
     {@code
      * interface ArchiveSearcher { String search(String target); }
      * class App {
      *   ExecutorService executor = ...
      *   ArchiveSearcher searcher = ...
      *   void showSearch(final String target)
      *       throws InterruptedException {
    - *     Future<String> future
    - *       = executor.submit(new Callable<String>() {
    + *     Future future
    + *       = executor.submit(new Callable() {
      *         public String call() {
      *             return searcher.search(target);
      *         }});
    @@ -70,20 +70,18 @@ package java.util.concurrent;
      *       displayText(future.get()); // use future
      *     } catch (ExecutionException ex) { cleanup(); return; }
      *   }
    - * }
    - * 
    + * }}
    * * The {@link FutureTask} class is an implementation of Future that * implements Runnable, and so may be executed by an Executor. * For example, the above construction with submit could be replaced by: - *
    - *     FutureTask<String> future =
    - *       new FutureTask<String>(new Callable<String>() {
    + *  
     {@code
    + *     FutureTask future =
    + *       new FutureTask(new Callable() {
      *         public String call() {
      *           return searcher.search(target);
      *       }});
    - *     executor.execute(future);
    - * 
    + * executor.execute(future);}
    * *

    Memory consistency effects: Actions taken by the asynchronous computation * happen-before diff --git a/src/share/classes/java/util/concurrent/FutureTask.java b/src/share/classes/java/util/concurrent/FutureTask.java index c77b6d3ced4205eafabc77f82da4a94dcbd0a4dd..dd7a51edf712686fa929d2a249893bed12f9ec38 100644 --- a/src/share/classes/java/util/concurrent/FutureTask.java +++ b/src/share/classes/java/util/concurrent/FutureTask.java @@ -85,7 +85,7 @@ public class FutureTask implements RunnableFuture { * @param result the result to return on successful completion. If * you don't need a particular result, consider using * constructions of the form: - * Future<?> f = new FutureTask<Object>(runnable, null) + * {@code Future f = new FutureTask(runnable, null)} * @throws NullPointerException if runnable is null */ public FutureTask(Runnable runnable, V result) { diff --git a/src/share/classes/java/util/concurrent/LinkedBlockingDeque.java b/src/share/classes/java/util/concurrent/LinkedBlockingDeque.java index 13901e842f72a910e1d4c42aab9770741e6b9e36..8051ccaa8483f71f0f873515a27f1880b051ab6f 100644 --- a/src/share/classes/java/util/concurrent/LinkedBlockingDeque.java +++ b/src/share/classes/java/util/concurrent/LinkedBlockingDeque.java @@ -1004,12 +1004,13 @@ public class LinkedBlockingDeque /** * 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). - * The returned {@code Iterator} is a "weakly consistent" iterator that + * + *

    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. + * 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. * * @return an iterator over the elements in this deque in proper sequence */ @@ -1021,12 +1022,13 @@ public class LinkedBlockingDeque * Returns an iterator over the elements in this deque in reverse * sequential order. The elements will be returned in order from * last (tail) to first (head). - * The returned {@code Iterator} is a "weakly consistent" iterator that + * + *

    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. + * 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. */ public Iterator descendingIterator() { return new DescendingItr(); diff --git a/src/share/classes/java/util/concurrent/RecursiveAction.java b/src/share/classes/java/util/concurrent/RecursiveAction.java index 40bcc88f0f8fe4a29fa48d8dd514b74a6ecdb5ff..e13bc4b55781dd332a23163e8d4c4ae7d306af0a 100644 --- a/src/share/classes/java/util/concurrent/RecursiveAction.java +++ b/src/share/classes/java/util/concurrent/RecursiveAction.java @@ -159,7 +159,9 @@ public abstract class RecursiveAction extends ForkJoinTask { protected abstract void compute(); /** - * Always returns null. + * Always returns {@code null}. + * + * @return {@code null} always */ public final Void getRawResult() { return null; } diff --git a/src/share/classes/java/util/concurrent/ScheduledExecutorService.java b/src/share/classes/java/util/concurrent/ScheduledExecutorService.java index a8d2f4041831f29b625998e7d48176779927fa32..e9d5d150afc99067c534d7405449507e6f8aa9f1 100644 --- a/src/share/classes/java/util/concurrent/ScheduledExecutorService.java +++ b/src/share/classes/java/util/concurrent/ScheduledExecutorService.java @@ -72,24 +72,23 @@ import java.util.*; * Here is a class with a method that sets up a ScheduledExecutorService * to beep every ten seconds for an hour: * - *

    + *  
     {@code
      * import static java.util.concurrent.TimeUnit.*;
      * class BeeperControl {
    - *    private final ScheduledExecutorService scheduler =
    - *       Executors.newScheduledThreadPool(1);
    + *   private final ScheduledExecutorService scheduler =
    + *     Executors.newScheduledThreadPool(1);
      *
    - *    public void beepForAnHour() {
    - *        final Runnable beeper = new Runnable() {
    - *                public void run() { System.out.println("beep"); }
    - *            };
    - *        final ScheduledFuture<?> beeperHandle =
    - *            scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
    - *        scheduler.schedule(new Runnable() {
    - *                public void run() { beeperHandle.cancel(true); }
    - *            }, 60 * 60, SECONDS);
    - *    }
    - * }
    - * 
    + * public void beepForAnHour() { + * final Runnable beeper = new Runnable() { + * public void run() { System.out.println("beep"); } + * }; + * final ScheduledFuture beeperHandle = + * scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS); + * scheduler.schedule(new Runnable() { + * public void run() { beeperHandle.cancel(true); } + * }, 60 * 60, SECONDS); + * } + * }}
    * * @since 1.5 * @author Doug Lea diff --git a/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java b/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java index 67c23fe99d79351d2bf83318761f4baf521ac3e2..46961b7aa40a43bf01bd9c0107b1ea618e4d6cb5 100644 --- a/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java +++ b/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java @@ -62,8 +62,8 @@ import java.util.*; * time of cancellation. * *

    Successive executions of a task scheduled via - * scheduleAtFixedRate or - * scheduleWithFixedDelay do not overlap. While different + * {@code scheduleAtFixedRate} or + * {@code scheduleWithFixedDelay} do not overlap. While different * executions may be performed by different threads, the effects of * prior executions happen-before @@ -436,7 +436,7 @@ public class ScheduledThreadPoolExecutor * @throws NullPointerException if {@code threadFactory} is null */ public ScheduledThreadPoolExecutor(int corePoolSize, - ThreadFactory threadFactory) { + ThreadFactory threadFactory) { super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, new DelayedWorkQueue(), threadFactory); } @@ -453,7 +453,7 @@ public class ScheduledThreadPoolExecutor * @throws NullPointerException if {@code handler} is null */ public ScheduledThreadPoolExecutor(int corePoolSize, - RejectedExecutionHandler handler) { + RejectedExecutionHandler handler) { super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, new DelayedWorkQueue(), handler); } @@ -473,8 +473,8 @@ public class ScheduledThreadPoolExecutor * {@code handler} is null */ public ScheduledThreadPoolExecutor(int corePoolSize, - ThreadFactory threadFactory, - RejectedExecutionHandler handler) { + ThreadFactory threadFactory, + RejectedExecutionHandler handler) { super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, new DelayedWorkQueue(), threadFactory, handler); } diff --git a/src/share/classes/java/util/concurrent/Semaphore.java b/src/share/classes/java/util/concurrent/Semaphore.java index 96a4719148d7397f8469ab773beb1e1be2671959..56c233fb3a7ba7ede0fe838fa78f8a5c7d495185 100644 --- a/src/share/classes/java/util/concurrent/Semaphore.java +++ b/src/share/classes/java/util/concurrent/Semaphore.java @@ -223,7 +223,7 @@ public class Semaphore implements java.io.Serializable { /** * NonFair version */ - final static class NonfairSync extends Sync { + static final class NonfairSync extends Sync { private static final long serialVersionUID = -2694183684443567898L; NonfairSync(int permits) { @@ -238,7 +238,7 @@ public class Semaphore implements java.io.Serializable { /** * Fair version */ - final static class FairSync extends Sync { + static final class FairSync extends Sync { private static final long serialVersionUID = 2014338818796000944L; FairSync(int permits) { @@ -282,7 +282,7 @@ public class Semaphore implements java.io.Serializable { * else {@code false} */ public Semaphore(int permits, boolean fair) { - sync = (fair)? new FairSync(permits) : new NonfairSync(permits); + sync = fair ? new FairSync(permits) : new NonfairSync(permits); } /** diff --git a/src/share/classes/java/util/concurrent/ThreadLocalRandom.java b/src/share/classes/java/util/concurrent/ThreadLocalRandom.java index c8a67dd651022703ce4bddcf8235fbbbedec4b2f..69f5fbcb40481b1350ba7921f8c7a9f7e260096e 100644 --- a/src/share/classes/java/util/concurrent/ThreadLocalRandom.java +++ b/src/share/classes/java/util/concurrent/ThreadLocalRandom.java @@ -63,9 +63,9 @@ import java.util.Random; */ public class ThreadLocalRandom extends Random { // same constants as Random, but must be redeclared because private - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; /** * The random seed. We can't use super.seed. diff --git a/src/share/classes/java/util/concurrent/TimeUnit.java b/src/share/classes/java/util/concurrent/TimeUnit.java index 5a18a5b01c01c45c0675213f35d44be898199b35..236e553bc6c6b773971bcee742822c0645200476 100644 --- a/src/share/classes/java/util/concurrent/TimeUnit.java +++ b/src/share/classes/java/util/concurrent/TimeUnit.java @@ -53,12 +53,12 @@ package java.util.concurrent; * java.util.concurrent.locks.Lock lock} is not available: * *

      Lock lock = ...;
    - *  if ( lock.tryLock(50L, TimeUnit.MILLISECONDS) ) ...
    + *  if (lock.tryLock(50L, TimeUnit.MILLISECONDS)) ...
      * 
    * while this code will timeout in 50 seconds: *
      *  Lock lock = ...;
    - *  if ( lock.tryLock(50L, TimeUnit.SECONDS) ) ...
    + *  if (lock.tryLock(50L, TimeUnit.SECONDS)) ...
      * 
    * * Note however, that there is no guarantee that a particular timeout @@ -291,7 +291,8 @@ public enum TimeUnit { abstract int excessNanos(long d, long m); /** - * Performs a timed Object.wait using this time unit. + * Performs a timed {@link Object#wait(long, int) Object.wait} + * using this time unit. * This is a convenience method that converts timeout arguments * into the form required by the Object.wait method. * @@ -299,21 +300,22 @@ public enum TimeUnit { * method (see {@link BlockingQueue#poll BlockingQueue.poll}) * using: * - *
      public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException {
    -     *    while (empty) {
    -     *      unit.timedWait(this, timeout);
    -     *      ...
    -     *    }
    -     *  }
    + *
     {@code
    +     * public synchronized Object poll(long timeout, TimeUnit unit)
    +     *     throws InterruptedException {
    +     *   while (empty) {
    +     *     unit.timedWait(this, timeout);
    +     *     ...
    +     *   }
    +     * }}
    * * @param obj the object to wait on * @param timeout the maximum time to wait. If less than * or equal to zero, do not wait at all. - * @throws InterruptedException if interrupted while waiting. - * @see Object#wait(long, int) + * @throws InterruptedException if interrupted while waiting */ public void timedWait(Object obj, long timeout) - throws InterruptedException { + throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); @@ -322,17 +324,18 @@ public enum TimeUnit { } /** - * Performs a timed Thread.join using this time unit. + * Performs a timed {@link Thread#join(long, int) Thread.join} + * using this time unit. * This is a convenience method that converts time arguments into the * form required by the Thread.join method. + * * @param thread the thread to wait for * @param timeout the maximum time to wait. If less than * or equal to zero, do not wait at all. - * @throws InterruptedException if interrupted while waiting. - * @see Thread#join(long, int) + * @throws InterruptedException if interrupted while waiting */ public void timedJoin(Thread thread, long timeout) - throws InterruptedException { + throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); @@ -341,13 +344,14 @@ public enum TimeUnit { } /** - * Performs a Thread.sleep using this unit. + * Performs a {@link Thread#sleep(long, int) Thread.sleep} using + * this time unit. * This is a convenience method that converts time arguments into the * form required by the Thread.sleep method. + * * @param timeout the minimum time to sleep. If less than * or equal to zero, do not sleep at all. - * @throws InterruptedException if interrupted while sleeping. - * @see Thread#sleep + * @throws InterruptedException if interrupted while sleeping */ public void sleep(long timeout) throws InterruptedException { if (timeout > 0) { diff --git a/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java index 9073254b12264bf163b55716d1fb8ec7818db4f6..7ea3a8012d5f40712be2a7804adecdebd6ac01b5 100644 --- a/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java +++ b/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java @@ -55,7 +55,7 @@ import java.lang.reflect.*; * @author Doug Lea * @param The type of the object holding the updatable field */ -public abstract class AtomicIntegerFieldUpdater { +public abstract class AtomicIntegerFieldUpdater { /** * Creates and returns an updater for objects with the given field. * The Class argument is needed to check that reflective types and @@ -279,7 +279,7 @@ public abstract class AtomicIntegerFieldUpdater { sun.reflect.misc.ReflectUtil.ensureMemberAccess( caller, tclass, null, modifiers); sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); - } catch(Exception ex) { + } catch (Exception ex) { throw new RuntimeException(ex); } diff --git a/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java index 8a81dbc9a8834e59a5eba639c40bca989a6f2cd2..22a1d5eecbea767bc38f5891d91a6e8b23c9bef4 100644 --- a/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java +++ b/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java @@ -55,7 +55,7 @@ import java.lang.reflect.*; * @author Doug Lea * @param The type of the object holding the updatable field */ -public abstract class AtomicLongFieldUpdater { +public abstract class AtomicLongFieldUpdater { /** * Creates and returns an updater for objects with the given field. * The Class argument is needed to check that reflective types and @@ -278,7 +278,7 @@ public abstract class AtomicLongFieldUpdater { sun.reflect.misc.ReflectUtil.ensureMemberAccess( caller, tclass, null, modifiers); sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); - } catch(Exception ex) { + } catch (Exception ex) { throw new RuntimeException(ex); } @@ -331,7 +331,7 @@ public abstract class AtomicLongFieldUpdater { if (cclass.isInstance(obj)) { return; } - throw new RuntimeException ( + throw new RuntimeException( new IllegalAccessException("Class " + cclass.getName() + " can not access a protected member of class " + @@ -361,7 +361,7 @@ public abstract class AtomicLongFieldUpdater { sun.reflect.misc.ReflectUtil.ensureMemberAccess( caller, tclass, null, modifiers); sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); - } catch(Exception ex) { + } catch (Exception ex) { throw new RuntimeException(ex); } @@ -387,7 +387,7 @@ public abstract class AtomicLongFieldUpdater { public boolean compareAndSet(T obj, long expect, long update) { if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - synchronized(this) { + synchronized (this) { long v = unsafe.getLong(obj, offset); if (v != expect) return false; @@ -402,7 +402,7 @@ public abstract class AtomicLongFieldUpdater { public void set(T obj, long newValue) { if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - synchronized(this) { + synchronized (this) { unsafe.putLong(obj, offset, newValue); } } @@ -413,7 +413,7 @@ public abstract class AtomicLongFieldUpdater { public long get(T obj) { if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - synchronized(this) { + synchronized (this) { return unsafe.getLong(obj, offset); } } @@ -422,7 +422,7 @@ public abstract class AtomicLongFieldUpdater { if (cclass.isInstance(obj)) { return; } - throw new RuntimeException ( + throw new RuntimeException( new IllegalAccessException("Class " + cclass.getName() + " can not access a protected member of class " + diff --git a/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java index ec2083294707cb00d7f5abd6b768516b20d5364f..c58fd30139f487bb7392a11d8ad04a913e6cc37a 100644 --- a/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java +++ b/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java @@ -45,13 +45,13 @@ import java.lang.reflect.*; * independently subject to atomic updates. For example, a tree node * might be declared as * - *
    + *  
     {@code
      * class Node {
      *   private volatile Node left, right;
      *
    - *   private static final AtomicReferenceFieldUpdater<Node, Node> leftUpdater =
    + *   private static final AtomicReferenceFieldUpdater leftUpdater =
      *     AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "left");
    - *   private static AtomicReferenceFieldUpdater<Node, Node> rightUpdater =
    + *   private static AtomicReferenceFieldUpdater rightUpdater =
      *     AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "right");
      *
      *   Node getLeft() { return left;  }
    @@ -59,8 +59,7 @@ import java.lang.reflect.*;
      *     return leftUpdater.compareAndSet(this, expect, update);
      *   }
      *   // ... and so on
    - * }
    - * 
    + * }}
    * *

    Note that the guarantees of the {@code compareAndSet} * method in this class are weaker than in other atomic classes. @@ -74,7 +73,7 @@ import java.lang.reflect.*; * @param The type of the object holding the updatable field * @param The type of the field */ -public abstract class AtomicReferenceFieldUpdater { +public abstract class AtomicReferenceFieldUpdater { /** * Creates and returns an updater for objects with the given field. @@ -291,7 +290,7 @@ public abstract class AtomicReferenceFieldUpdater { if (cclass.isInstance(obj)) { return; } - throw new RuntimeException ( + throw new RuntimeException( new IllegalAccessException("Class " + cclass.getName() + " can not access a protected member of class " + diff --git a/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java b/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java index c45c2cef1f4739f085ffdc86aada4f3f25dbbecf..605276e27b517b60c40b4dd3b0e0fed03653d14c 100644 --- a/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java +++ b/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java @@ -990,7 +990,8 @@ public abstract class AbstractQueuedLongSynchronizer * can represent anything you like. * @throws InterruptedException if the current thread is interrupted */ - public final void acquireInterruptibly(long arg) throws InterruptedException { + public final void acquireInterruptibly(long arg) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); if (!tryAcquire(arg)) @@ -1014,7 +1015,8 @@ public abstract class AbstractQueuedLongSynchronizer * @return {@code true} if acquired; {@code false} if timed out * @throws InterruptedException if the current thread is interrupted */ - public final boolean tryAcquireNanos(long arg, long nanosTimeout) throws InterruptedException { + public final boolean tryAcquireNanos(long arg, long nanosTimeout) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); return tryAcquire(arg) || @@ -1070,7 +1072,8 @@ public abstract class AbstractQueuedLongSynchronizer * you like. * @throws InterruptedException if the current thread is interrupted */ - public final void acquireSharedInterruptibly(long arg) throws InterruptedException { + public final void acquireSharedInterruptibly(long arg) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); if (tryAcquireShared(arg) < 0) @@ -1093,7 +1096,8 @@ public abstract class AbstractQueuedLongSynchronizer * @return {@code true} if acquired; {@code false} if timed out * @throws InterruptedException if the current thread is interrupted */ - public final boolean tryAcquireSharedNanos(long arg, long nanosTimeout) throws InterruptedException { + public final boolean tryAcquireSharedNanos(long arg, long nanosTimeout) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); return tryAcquireShared(arg) >= 0 || @@ -1841,7 +1845,8 @@ public abstract class AbstractQueuedLongSynchronizer *

  • If interrupted while blocked in step 4, throw InterruptedException. * */ - public final long awaitNanos(long nanosTimeout) throws InterruptedException { + public final long awaitNanos(long nanosTimeout) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Node node = addConditionWaiter(); @@ -1885,7 +1890,8 @@ public abstract class AbstractQueuedLongSynchronizer *
  • If timed out while blocked in step 4, return false, else true. * */ - public final boolean awaitUntil(Date deadline) throws InterruptedException { + public final boolean awaitUntil(Date deadline) + throws InterruptedException { if (deadline == null) throw new NullPointerException(); long abstime = deadline.getTime(); @@ -1928,7 +1934,8 @@ public abstract class AbstractQueuedLongSynchronizer *
  • If timed out while blocked in step 4, return false, else true. * */ - public final boolean await(long time, TimeUnit unit) throws InterruptedException { + public final boolean await(long time, TimeUnit unit) + throws InterruptedException { if (unit == null) throw new NullPointerException(); long nanosTimeout = unit.toNanos(time); @@ -2084,7 +2091,7 @@ public abstract class AbstractQueuedLongSynchronizer /** * CAS waitStatus field of a node. */ - private final static boolean compareAndSetWaitStatus(Node node, + private static final boolean compareAndSetWaitStatus(Node node, int expect, int update) { return unsafe.compareAndSwapInt(node, waitStatusOffset, @@ -2094,7 +2101,7 @@ public abstract class AbstractQueuedLongSynchronizer /** * CAS next field of a node. */ - private final static boolean compareAndSetNext(Node node, + private static final boolean compareAndSetNext(Node node, Node expect, Node update) { return unsafe.compareAndSwapObject(node, nextOffset, expect, update); diff --git a/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java b/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java index d17c5d08d0ea11723e93fdd1c24d8c53d9acc035..8075aea7dea47df3fa62fd0b2e2d95ea76dc6a6c 100644 --- a/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java +++ b/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java @@ -265,7 +265,7 @@ import sun.misc.Unsafe; * boolean isSignalled() { return getState() != 0; } * * protected int tryAcquireShared(int ignore) { - * return isSignalled()? 1 : -1; + * return isSignalled() ? 1 : -1; * } * * protected boolean tryReleaseShared(int ignore) { @@ -1213,7 +1213,8 @@ public abstract class AbstractQueuedSynchronizer * can represent anything you like. * @throws InterruptedException if the current thread is interrupted */ - public final void acquireInterruptibly(int arg) throws InterruptedException { + public final void acquireInterruptibly(int arg) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); if (!tryAcquire(arg)) @@ -1237,7 +1238,8 @@ public abstract class AbstractQueuedSynchronizer * @return {@code true} if acquired; {@code false} if timed out * @throws InterruptedException if the current thread is interrupted */ - public final boolean tryAcquireNanos(int arg, long nanosTimeout) throws InterruptedException { + public final boolean tryAcquireNanos(int arg, long nanosTimeout) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); return tryAcquire(arg) || @@ -1293,7 +1295,8 @@ public abstract class AbstractQueuedSynchronizer * you like. * @throws InterruptedException if the current thread is interrupted */ - public final void acquireSharedInterruptibly(int arg) throws InterruptedException { + public final void acquireSharedInterruptibly(int arg) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); if (tryAcquireShared(arg) < 0) @@ -1316,7 +1319,8 @@ public abstract class AbstractQueuedSynchronizer * @return {@code true} if acquired; {@code false} if timed out * @throws InterruptedException if the current thread is interrupted */ - public final boolean tryAcquireSharedNanos(int arg, long nanosTimeout) throws InterruptedException { + public final boolean tryAcquireSharedNanos(int arg, long nanosTimeout) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); return tryAcquireShared(arg) >= 0 || @@ -2062,7 +2066,8 @@ public abstract class AbstractQueuedSynchronizer *
  • If interrupted while blocked in step 4, throw InterruptedException. * */ - public final long awaitNanos(long nanosTimeout) throws InterruptedException { + public final long awaitNanos(long nanosTimeout) + throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); Node node = addConditionWaiter(); @@ -2106,7 +2111,8 @@ public abstract class AbstractQueuedSynchronizer *
  • If timed out while blocked in step 4, return false, else true. * */ - public final boolean awaitUntil(Date deadline) throws InterruptedException { + public final boolean awaitUntil(Date deadline) + throws InterruptedException { if (deadline == null) throw new NullPointerException(); long abstime = deadline.getTime(); @@ -2149,7 +2155,8 @@ public abstract class AbstractQueuedSynchronizer *
  • If timed out while blocked in step 4, return false, else true. * */ - public final boolean await(long time, TimeUnit unit) throws InterruptedException { + public final boolean await(long time, TimeUnit unit) + throws InterruptedException { if (unit == null) throw new NullPointerException(); long nanosTimeout = unit.toNanos(time); @@ -2305,7 +2312,7 @@ public abstract class AbstractQueuedSynchronizer /** * CAS waitStatus field of a node. */ - private final static boolean compareAndSetWaitStatus(Node node, + private static final boolean compareAndSetWaitStatus(Node node, int expect, int update) { return unsafe.compareAndSwapInt(node, waitStatusOffset, @@ -2315,7 +2322,7 @@ public abstract class AbstractQueuedSynchronizer /** * CAS next field of a node. */ - private final static boolean compareAndSetNext(Node node, + private static final boolean compareAndSetNext(Node node, Node expect, Node update) { return unsafe.compareAndSwapObject(node, nextOffset, expect, update); diff --git a/src/share/classes/java/util/concurrent/locks/LockSupport.java b/src/share/classes/java/util/concurrent/locks/LockSupport.java index 9751f418c17270ced5511dcf844f7c2470b4f107..9c966406b313d0ab39c0c60cc83a127bceb34a9f 100644 --- a/src/share/classes/java/util/concurrent/locks/LockSupport.java +++ b/src/share/classes/java/util/concurrent/locks/LockSupport.java @@ -200,8 +200,8 @@ public class LockSupport { *
  • Some other thread invokes {@link #unpark unpark} with the * current thread as the target; or * - *
  • Some other thread {@linkplain Thread#interrupt interrupts} the current - * thread; or + *
  • Some other thread {@linkplain Thread#interrupt interrupts} + * the current thread; or * *
  • The specified waiting time elapses; or * diff --git a/src/share/classes/java/util/concurrent/locks/ReentrantLock.java b/src/share/classes/java/util/concurrent/locks/ReentrantLock.java index 9cc3bf4d011159dae01f1ebd73090c1a1002100e..4cbc562b82015113a30083570f71c442ea966e44 100644 --- a/src/share/classes/java/util/concurrent/locks/ReentrantLock.java +++ b/src/share/classes/java/util/concurrent/locks/ReentrantLock.java @@ -116,7 +116,7 @@ public class ReentrantLock implements Lock, java.io.Serializable { * into fair and nonfair versions below. Uses AQS state to * represent the number of holds on the lock. */ - static abstract class Sync extends AbstractQueuedSynchronizer { + abstract static class Sync extends AbstractQueuedSynchronizer { private static final long serialVersionUID = -5179523762034025860L; /** @@ -200,7 +200,7 @@ public class ReentrantLock implements Lock, java.io.Serializable { /** * Sync object for non-fair locks */ - final static class NonfairSync extends Sync { + static final class NonfairSync extends Sync { private static final long serialVersionUID = 7316153563782823691L; /** @@ -222,7 +222,7 @@ public class ReentrantLock implements Lock, java.io.Serializable { /** * Sync object for fair locks */ - final static class FairSync extends Sync { + static final class FairSync extends Sync { private static final long serialVersionUID = -3000897897090466540L; final void lock() { @@ -269,7 +269,7 @@ public class ReentrantLock implements Lock, java.io.Serializable { * @param fair {@code true} if this lock should use a fair ordering policy */ public ReentrantLock(boolean fair) { - sync = (fair)? new FairSync() : new NonfairSync(); + sync = fair ? new FairSync() : new NonfairSync(); } /** @@ -440,7 +440,8 @@ public class ReentrantLock implements Lock, java.io.Serializable { * @throws NullPointerException if the time unit is null * */ - public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { + public boolean tryLock(long timeout, TimeUnit unit) + throws InterruptedException { return sync.tryAcquireNanos(1, unit.toNanos(timeout)); } diff --git a/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java b/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java index b327b65c4de00b85693c4dc6a0a37eb63aefdbbd..39b9c0e894dfaf8080e20ba2d9a2cb8b2da14035 100644 --- a/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java +++ b/src/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java @@ -155,7 +155,7 @@ import java.util.*; * } * // Downgrade by acquiring read lock before releasing write lock * rwl.readLock().lock(); - * } finally { + * } finally { * rwl.writeLock().unlock(); // Unlock write, still hold read * } * } @@ -215,7 +215,8 @@ import java.util.*; * @author Doug Lea * */ -public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializable { +public class ReentrantReadWriteLock + implements ReadWriteLock, java.io.Serializable { private static final long serialVersionUID = -6992448646407690164L; /** Inner class providing readlock */ private final ReentrantReadWriteLock.ReadLock readerLock; @@ -251,7 +252,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab * Synchronization implementation for ReentrantReadWriteLock. * Subclassed into fair and nonfair versions. */ - static abstract class Sync extends AbstractQueuedSynchronizer { + abstract static class Sync extends AbstractQueuedSynchronizer { private static final long serialVersionUID = 6317671515068378041L; /* @@ -618,7 +619,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab final Thread getOwner() { // Must read state before owner to ensure memory consistency - return ((exclusiveCount(getState()) == 0)? + return ((exclusiveCount(getState()) == 0) ? null : getExclusiveOwnerThread()); } @@ -669,7 +670,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab /** * Nonfair version of Sync */ - final static class NonfairSync extends Sync { + static final class NonfairSync extends Sync { private static final long serialVersionUID = -8159625535654395037L; final boolean writerShouldBlock() { return false; // writers can always barge @@ -689,7 +690,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab /** * Fair version of Sync */ - final static class FairSync extends Sync { + static final class FairSync extends Sync { private static final long serialVersionUID = -2274990926593161451L; final boolean writerShouldBlock() { return hasQueuedPredecessors(); @@ -702,7 +703,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab /** * The lock returned by method {@link ReentrantReadWriteLock#readLock}. */ - public static class ReadLock implements Lock, java.io.Serializable { + public static class ReadLock implements Lock, java.io.Serializable { private static final long serialVersionUID = -5992448646407690164L; private final Sync sync; @@ -867,7 +868,8 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab * @throws NullPointerException if the time unit is null * */ - public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { + public boolean tryLock(long timeout, TimeUnit unit) + throws InterruptedException { return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout)); } @@ -908,7 +910,7 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab /** * The lock returned by method {@link ReentrantReadWriteLock#writeLock}. */ - public static class WriteLock implements Lock, java.io.Serializable { + public static class WriteLock implements Lock, java.io.Serializable { private static final long serialVersionUID = -4992448646407690164L; private final Sync sync; @@ -1108,7 +1110,8 @@ public class ReentrantReadWriteLock implements ReadWriteLock, java.io.Serializab * @throws NullPointerException if the time unit is null * */ - public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { + public boolean tryLock(long timeout, TimeUnit unit) + throws InterruptedException { return sync.tryAcquireNanos(1, unit.toNanos(timeout)); } diff --git a/test/java/util/concurrent/BlockingQueue/Interrupt.java b/test/java/util/concurrent/BlockingQueue/Interrupt.java index 418515ded51fa1479fb893bf00f6564fe04ec90f..aafa92c42ed6c1df1b871717a31456feb256cf60 100644 --- a/test/java/util/concurrent/BlockingQueue/Interrupt.java +++ b/test/java/util/concurrent/BlockingQueue/Interrupt.java @@ -136,5 +136,5 @@ public class Interrupt { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + private abstract static class Fun {abstract void f() throws Throwable;} } diff --git a/test/java/util/concurrent/BlockingQueue/LoopHelpers.java b/test/java/util/concurrent/BlockingQueue/LoopHelpers.java index f6bac816a7babe3f6b058ac3aa74ce76bb1979e2..5bf6d0dbbee5900c0abe3cfa9a55aa6d8313e645 100644 --- a/test/java/util/concurrent/BlockingQueue/LoopHelpers.java +++ b/test/java/util/concurrent/BlockingQueue/LoopHelpers.java @@ -79,9 +79,9 @@ class LoopHelpers { * Basically same as java.util.Random. */ public static class SimpleRandom { - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; static final AtomicLong seq = new AtomicLong(1); private long seed = System.nanoTime() + seq.getAndIncrement(); diff --git a/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java b/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java index f6bac816a7babe3f6b058ac3aa74ce76bb1979e2..5bf6d0dbbee5900c0abe3cfa9a55aa6d8313e645 100644 --- a/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java +++ b/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java @@ -79,9 +79,9 @@ class LoopHelpers { * Basically same as java.util.Random. */ public static class SimpleRandom { - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; static final AtomicLong seq = new AtomicLong(1); private long seed = System.nanoTime() + seq.getAndIncrement(); diff --git a/test/java/util/concurrent/ConcurrentHashMap/MapCheck.java b/test/java/util/concurrent/ConcurrentHashMap/MapCheck.java index e9ca263c91088e424d95d4ef06ae0ba246103c82..c6075c131b94a45119d763def02734e235fa6ad2 100644 --- a/test/java/util/concurrent/ConcurrentHashMap/MapCheck.java +++ b/test/java/util/concurrent/ConcurrentHashMap/MapCheck.java @@ -34,7 +34,7 @@ /* * @test * @bug 4486658 - * @compile MapCheck.java + * @compile -source 1.5 MapCheck.java * @run main/timeout=240 MapCheck * @summary Times and checks basic map operations */ @@ -64,7 +64,7 @@ public class MapCheck { if (args.length > 0) { try { mapClass = Class.forName(args[0]); - } catch(ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new RuntimeException("Class " + args[0] + " not found."); } } @@ -102,7 +102,7 @@ public class MapCheck { try { Map m = (Map)cl.newInstance(); return m; - } catch(Exception e) { + } catch (Exception e) { throw new RuntimeException("Can't instantiate " + cl + ": " + e); } } @@ -139,7 +139,7 @@ public class MapCheck { } } timer.finish(); - reallyAssert (sum == expect * iters); + reallyAssert(sum == expect * iters); } static void t2(String nm, int n, Map s, Object[] key, int expect) { @@ -149,7 +149,7 @@ public class MapCheck { if (s.remove(key[i]) != null) ++sum; } timer.finish(); - reallyAssert (sum == expect); + reallyAssert(sum == expect); } static void t3(String nm, int n, Map s, Object[] key, int expect) { @@ -159,7 +159,7 @@ public class MapCheck { if (s.put(key[i], absent[i & absentMask]) == null) ++sum; } timer.finish(); - reallyAssert (sum == expect); + reallyAssert(sum == expect); } static void t4(String nm, int n, Map s, Object[] key, int expect) { @@ -169,7 +169,7 @@ public class MapCheck { if (s.containsKey(key[i])) ++sum; } timer.finish(); - reallyAssert (sum == expect); + reallyAssert(sum == expect); } static void t5(String nm, int n, Map s, Object[] key, int expect) { @@ -179,7 +179,7 @@ public class MapCheck { if (s.remove(key[i]) != null) ++sum; } timer.finish(); - reallyAssert (sum == expect); + reallyAssert(sum == expect); } static void t6(String nm, int n, Map s, Object[] k1, Object[] k2) { @@ -190,7 +190,7 @@ public class MapCheck { if (s.get(k2[i & absentMask]) != null) ++sum; } timer.finish(); - reallyAssert (sum == n); + reallyAssert(sum == n); } static void t7(String nm, int n, Map s, Object[] k1, Object[] k2) { @@ -201,7 +201,7 @@ public class MapCheck { if (s.containsKey(k2[i & absentMask])) ++sum; } timer.finish(); - reallyAssert (sum == n); + reallyAssert(sum == n); } static void t8(String nm, int n, Map s, Object[] key, int expect) { @@ -211,7 +211,7 @@ public class MapCheck { if (s.get(key[i]) != null) ++sum; } timer.finish(); - reallyAssert (sum == expect); + reallyAssert(sum == expect); } @@ -223,7 +223,7 @@ public class MapCheck { for (int i = 0; i < absentSize; i += step) if (s.containsValue(absent[i])) ++sum; timer.finish(); - reallyAssert (sum != 0); + reallyAssert(sum != 0); } @@ -235,7 +235,7 @@ public class MapCheck { if (ks.contains(key[i])) ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); } @@ -243,37 +243,37 @@ public class MapCheck { int sum = 0; timer.start("Iter Key ", size); for (Iterator it = s.keySet().iterator(); it.hasNext(); ) { - if(it.next() != MISSING) + if (it.next() != MISSING) ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); } static void ittest2(Map s, int size) { int sum = 0; timer.start("Iter Value ", size); for (Iterator it = s.values().iterator(); it.hasNext(); ) { - if(it.next() != MISSING) + if (it.next() != MISSING) ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); } static void ittest3(Map s, int size) { int sum = 0; timer.start("Iter Entry ", size); for (Iterator it = s.entrySet().iterator(); it.hasNext(); ) { - if(it.next() != MISSING) + if (it.next() != MISSING) ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); } static void ittest4(Map s, int size, int pos) { IdentityHashMap seen = new IdentityHashMap(size); - reallyAssert (s.size() == size); + reallyAssert(s.size() == size); int sum = 0; timer.start("Iter XEntry ", size); Iterator it = s.entrySet().iterator(); @@ -287,9 +287,9 @@ public class MapCheck { if (x != MISSING) ++sum; } - reallyAssert (s.containsKey(k)); + reallyAssert(s.containsKey(k)); it.remove(); - reallyAssert (!s.containsKey(k)); + reallyAssert(!s.containsKey(k)); while (it.hasNext()) { Map.Entry x = (Map.Entry)(it.next()); Object k2 = x.getKey(); @@ -298,12 +298,12 @@ public class MapCheck { ++sum; } - reallyAssert (s.size() == size-1); + reallyAssert(s.size() == size-1); s.put(k, v); - reallyAssert (seen.size() == size); + reallyAssert(seen.size() == size); timer.finish(); - reallyAssert (sum == size); - reallyAssert (s.size() == size); + reallyAssert(sum == size); + reallyAssert(s.size() == size); } @@ -324,7 +324,7 @@ public class MapCheck { ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); } static void entest2(Hashtable ht, int size) { @@ -335,7 +335,7 @@ public class MapCheck { ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); } @@ -349,7 +349,7 @@ public class MapCheck { ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); } static void entest4(Hashtable ht, int size) { @@ -361,7 +361,7 @@ public class MapCheck { ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); } static void entest(Map s, int size) { @@ -409,13 +409,13 @@ public class MapCheck { timer.start("Iter Equals ", size * 2); boolean eqt = s2.equals(s) && s.equals(s2); - reallyAssert (eqt); + reallyAssert(eqt); timer.finish(); timer.start("Iter HashCode ", size * 2); int shc = s.hashCode(); int s2hc = s2.hashCode(); - reallyAssert (shc == s2hc); + reallyAssert(shc == s2hc); timer.finish(); timer.start("Put (present) ", size); @@ -430,7 +430,7 @@ public class MapCheck { if (es2.contains(entry)) ++sum; } timer.finish(); - reallyAssert (sum == size); + reallyAssert(sum == size); t6("Get ", size, s2, key, absent); @@ -438,13 +438,13 @@ public class MapCheck { s2.put(key[size-1], absent[0]); timer.start("Iter Equals ", size * 2); eqt = s2.equals(s) && s.equals(s2); - reallyAssert (!eqt); + reallyAssert(!eqt); timer.finish(); timer.start("Iter HashCode ", size * 2); int s1h = s.hashCode(); int s2h = s2.hashCode(); - reallyAssert (s1h != s2h); + reallyAssert(s1h != s2h); timer.finish(); s2.put(key[size-1], hold); @@ -455,12 +455,12 @@ public class MapCheck { es.remove(s2i.next()); timer.finish(); - reallyAssert (s.isEmpty()); + reallyAssert(s.isEmpty()); timer.start("Clear ", size); s2.clear(); timer.finish(); - reallyAssert (s2.isEmpty() && s.isEmpty()); + reallyAssert(s2.isEmpty() && s.isEmpty()); } static void stest(Map s, int size) throws Exception { @@ -489,7 +489,7 @@ public class MapCheck { System.out.print(time + "ms"); if (s instanceof IdentityHashMap) return; - reallyAssert (s.equals(m)); + reallyAssert(s.equals(m)); } diff --git a/test/java/util/concurrent/ConcurrentHashMap/MapLoops.java b/test/java/util/concurrent/ConcurrentHashMap/MapLoops.java index 5f3d375515e7ecf2321fc1809d7f88f51f0fd8e9..53ed2919a9d82b1ef0580b8730b7cf5565bf10cb 100644 --- a/test/java/util/concurrent/ConcurrentHashMap/MapLoops.java +++ b/test/java/util/concurrent/ConcurrentHashMap/MapLoops.java @@ -34,7 +34,7 @@ /* * @test * @bug 4486658 - * @compile MapLoops.java + * @compile -source 1.5 MapLoops.java * @run main/timeout=1600 MapLoops * @summary Exercise multithreaded maps, by default ConcurrentHashMap. * Multithreaded hash table test. Each thread does a random walk @@ -225,7 +225,7 @@ public class MapLoops { barrier.await(); } catch (Throwable throwable) { - synchronized(System.err) { + synchronized (System.err) { System.err.println("--------------------------------"); throwable.printStackTrace(); } diff --git a/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java b/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java index f6bac816a7babe3f6b058ac3aa74ce76bb1979e2..5bf6d0dbbee5900c0abe3cfa9a55aa6d8313e645 100644 --- a/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java +++ b/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java @@ -79,9 +79,9 @@ class LoopHelpers { * Basically same as java.util.Random. */ public static class SimpleRandom { - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; static final AtomicLong seq = new AtomicLong(1); private long seed = System.nanoTime() + seq.getAndIncrement(); diff --git a/test/java/util/concurrent/CopyOnWriteArrayList/EqualsRace.java b/test/java/util/concurrent/CopyOnWriteArrayList/EqualsRace.java index ad063ea237aab85723e093d0fc53955ef1dae4a8..7bc8fab638b6995943ff4390928f82a455706dec 100644 --- a/test/java/util/concurrent/CopyOnWriteArrayList/EqualsRace.java +++ b/test/java/util/concurrent/CopyOnWriteArrayList/EqualsRace.java @@ -66,7 +66,7 @@ public class EqualsRace { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class CheckedThread extends Thread { + private abstract static class CheckedThread extends Thread { public abstract void realRun() throws Throwable; public void run() { try { realRun(); } catch (Throwable t) { unexpected(t); }}} diff --git a/test/java/util/concurrent/CopyOnWriteArraySet/RacingCows.java b/test/java/util/concurrent/CopyOnWriteArraySet/RacingCows.java index afde87549ed374e79abdae14621349b9760152a1..6d13dac3cca70e94efe46ae0912cdab9cceb0668 100644 --- a/test/java/util/concurrent/CopyOnWriteArraySet/RacingCows.java +++ b/test/java/util/concurrent/CopyOnWriteArraySet/RacingCows.java @@ -125,7 +125,7 @@ public class RacingCows { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class CheckedThread extends Thread { + private abstract static class CheckedThread extends Thread { public abstract void realRun() throws Throwable; public void run() { try { realRun(); } catch (Throwable t) { unexpected(t); }}} diff --git a/test/java/util/concurrent/CyclicBarrier/Basic.java b/test/java/util/concurrent/CyclicBarrier/Basic.java index b20a81ea2ffe314defba39e8b0ed7234bb8df86b..f0459d613d531c32bb1853f5779dbe36598efbbd 100644 --- a/test/java/util/concurrent/CyclicBarrier/Basic.java +++ b/test/java/util/concurrent/CyclicBarrier/Basic.java @@ -83,7 +83,7 @@ public class Basic { //---------------------------------------------------------------- // Convenience methods for creating threads that call CyclicBarrier.await //---------------------------------------------------------------- - private static abstract class Awaiter extends Thread { + private abstract static class Awaiter extends Thread { static AtomicInteger count = new AtomicInteger(1); { @@ -417,14 +417,14 @@ public class Basic { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - static abstract class Fun { abstract void f() throws Throwable; } + abstract static class Fun { abstract void f() throws Throwable; } private static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } catch (Throwable t) { if (k.isAssignableFrom(t.getClass())) pass(); else unexpected(t);}} - private static abstract class CheckedThread extends Thread { + private abstract static class CheckedThread extends Thread { abstract void realRun() throws Throwable; public void run() { try {realRun();} catch (Throwable t) {unexpected(t);}}} diff --git a/test/java/util/concurrent/Exchanger/ExchangeLoops.java b/test/java/util/concurrent/Exchanger/ExchangeLoops.java index b207b8c2d92f494c15ce51fd0c24a21ae3d08707..2055c056ca33215aae45ea7648b7372107484f46 100644 --- a/test/java/util/concurrent/Exchanger/ExchangeLoops.java +++ b/test/java/util/concurrent/Exchanger/ExchangeLoops.java @@ -34,7 +34,7 @@ /* * @test * @bug 4486658 - * @compile ExchangeLoops.java + * @compile -source 1.5 ExchangeLoops.java * @run main/timeout=720 ExchangeLoops * @summary checks to make sure a pipeline of exchangers passes data. */ @@ -78,9 +78,9 @@ public class ExchangeLoops { final Exchanger right; final CyclicBarrier barrier; volatile int result; - Stage (Exchanger left, - Exchanger right, - CyclicBarrier b, int iters) { + Stage(Exchanger left, + Exchanger right, + CyclicBarrier b, int iters) { this.left = left; this.right = right; barrier = b; diff --git a/test/java/util/concurrent/Exchanger/LoopHelpers.java b/test/java/util/concurrent/Exchanger/LoopHelpers.java index d3dd5b4a5ef182500f5f8c375c941c01e96bb1a9..6b65b8b2d4aa5b0eec43287030d252a71b89e0cd 100644 --- a/test/java/util/concurrent/Exchanger/LoopHelpers.java +++ b/test/java/util/concurrent/Exchanger/LoopHelpers.java @@ -78,9 +78,9 @@ class LoopHelpers { * Basically same as java.util.Random. */ public static class SimpleRandom { - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; static final AtomicLong seq = new AtomicLong(1); private long seed = System.nanoTime() + seq.getAndIncrement(); diff --git a/test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java b/test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java index 2c67ba5697d34270eadb9345d5587b005331f098..71c45e75f7fa3e7a28d804dc5ec8543587e50e4e 100644 --- a/test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java +++ b/test/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java @@ -34,7 +34,7 @@ /* * @test * @bug 4965960 - * @compile ExecutorCompletionServiceLoops.java + * @compile -source 1.5 ExecutorCompletionServiceLoops.java * @run main/timeout=3600 ExecutorCompletionServiceLoops * @summary Exercise ExecutorCompletionServiceLoops */ diff --git a/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java b/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java index d3dd5b4a5ef182500f5f8c375c941c01e96bb1a9..6b65b8b2d4aa5b0eec43287030d252a71b89e0cd 100644 --- a/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java +++ b/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java @@ -78,9 +78,9 @@ class LoopHelpers { * Basically same as java.util.Random. */ public static class SimpleRandom { - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; static final AtomicLong seq = new AtomicLong(1); private long seed = System.nanoTime() + seq.getAndIncrement(); diff --git a/test/java/util/concurrent/Executors/Throws.java b/test/java/util/concurrent/Executors/Throws.java index c310ad5c9ec801884e592d54c39b2b23bc66bc72..d98537931ee39f2139deb39cd2ea91681d29df08 100644 --- a/test/java/util/concurrent/Executors/Throws.java +++ b/test/java/util/concurrent/Executors/Throws.java @@ -122,7 +122,7 @@ public class Throws { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + private abstract static class Fun {abstract void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java b/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java index bd6c2e839da52eac2987c2d9d85d2f0c1e6042c8..4c6f12ba29d44486b50791b5fcb0b4a71ff79d76 100644 --- a/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java +++ b/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java @@ -87,7 +87,7 @@ public class BlockingTaskExecutor { * A helper class with a method to wait for a notification. * * The notification is received via the - * sendNotification method. + * {@code sendNotification} method. */ static class NotificationReceiver { /** Has the notifiee been notified? */ diff --git a/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java b/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java index c12f5cde94463d5ffc6e097b7c318e4658a6a3d1..6a0ca8c93df8c466dd66cce3fd4255ffa43e46fe 100644 --- a/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java +++ b/test/java/util/concurrent/FutureTask/CancelledFutureLoops.java @@ -34,7 +34,7 @@ /* * @test * @bug 4486658 - * @compile CancelledFutureLoops.java + * @compile -source 1.5 CancelledFutureLoops.java * @run main/timeout=2000 CancelledFutureLoops * @summary Checks for responsiveness of futures to cancellation. * Runs under the assumption that ITERS computations require more than @@ -64,10 +64,10 @@ public final class CancelledFutureLoops { try { new FutureLoop(i).test(); } - catch(BrokenBarrierException bb) { + catch (BrokenBarrierException bb) { // OK; ignore } - catch(ExecutionException ee) { + catch (ExecutionException ee) { // OK; ignore } Thread.sleep(TIMEOUT); diff --git a/test/java/util/concurrent/FutureTask/Customized.java b/test/java/util/concurrent/FutureTask/Customized.java index 1f1f8fb49391aa81922d203a7379c17ddc753951..5d107c58ad1ec473c83cb6b2b790b289c650ab2e 100644 --- a/test/java/util/concurrent/FutureTask/Customized.java +++ b/test/java/util/concurrent/FutureTask/Customized.java @@ -203,7 +203,7 @@ public class Customized { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + private abstract static class Fun {abstract void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/concurrent/FutureTask/LoopHelpers.java b/test/java/util/concurrent/FutureTask/LoopHelpers.java index d3dd5b4a5ef182500f5f8c375c941c01e96bb1a9..6b65b8b2d4aa5b0eec43287030d252a71b89e0cd 100644 --- a/test/java/util/concurrent/FutureTask/LoopHelpers.java +++ b/test/java/util/concurrent/FutureTask/LoopHelpers.java @@ -78,9 +78,9 @@ class LoopHelpers { * Basically same as java.util.Random. */ public static class SimpleRandom { - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; static final AtomicLong seq = new AtomicLong(1); private long seed = System.nanoTime() + seq.getAndIncrement(); diff --git a/test/java/util/concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java b/test/java/util/concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java index 2e0854b0fc7c21618fc87b8e1a115c71ae05abfc..bc34d00965fc0a7a5bd89b4add0617f15c60be35 100644 --- a/test/java/util/concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java +++ b/test/java/util/concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java @@ -161,11 +161,8 @@ public class DelayOverflow { if (x == null ? y == null : x.equals(y)) pass(); else fail(x + " not equal to " + y);} public static void main(String[] args) throws Throwable { - Class k = new Object(){}.getClass().getEnclosingClass(); - try {k.getMethod("instanceMain",String[].class) - .invoke( k.newInstance(), (Object) args);} - catch (Throwable e) {throw e.getCause();}} - public void instanceMain(String[] args) throws Throwable { + new DelayOverflow().instanceMain(args);} + void instanceMain(String[] args) throws Throwable { try {test(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} diff --git a/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java b/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java index 40d11e04b311b42619226b3f1157be6839b59540..4c69a594bcbad6670146287bc62a125ff41324b2 100644 --- a/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java +++ b/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java @@ -36,9 +36,9 @@ import java.util.concurrent.atomic.*; import static java.util.concurrent.TimeUnit.*; public class ConfigChanges { - final static ThreadGroup tg = new ThreadGroup("pool"); + static final ThreadGroup tg = new ThreadGroup("pool"); - final static Random rnd = new Random(); + static final Random rnd = new Random(); static void report(ThreadPoolExecutor tpe) { try { @@ -241,7 +241,7 @@ public class ConfigChanges { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + private abstract static class Fun {abstract void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/concurrent/ThreadPoolExecutor/Custom.java b/test/java/util/concurrent/ThreadPoolExecutor/Custom.java index 108ca7bd4fc6ce100bf4e712dddf267e86e514c7..d60bdcefdea872d9c4e829464c54e4f29a72f25a 100644 --- a/test/java/util/concurrent/ThreadPoolExecutor/Custom.java +++ b/test/java/util/concurrent/ThreadPoolExecutor/Custom.java @@ -43,7 +43,7 @@ public class Custom { private static class CustomTask extends FutureTask { - public final static AtomicInteger births = new AtomicInteger(0); + public static final AtomicInteger births = new AtomicInteger(0); CustomTask(Callable c) { super(c); births.getAndIncrement(); } CustomTask(Runnable r, V v) { super(r, v); births.getAndIncrement(); } } @@ -63,7 +63,7 @@ public class Custom { } private static class CustomSTPE extends ScheduledThreadPoolExecutor { - public final static AtomicInteger decorations = new AtomicInteger(0); + public static final AtomicInteger decorations = new AtomicInteger(0); CustomSTPE() { super(threadCount); } @@ -89,7 +89,7 @@ public class Custom { return count; } - private final static int threadCount = 10; + private static final int threadCount = 10; public static void main(String[] args) throws Throwable { CustomTPE tpe = new CustomTPE(); diff --git a/test/java/util/concurrent/ThreadPoolExecutor/ScheduledTickleService.java b/test/java/util/concurrent/ThreadPoolExecutor/ScheduledTickleService.java index 94c71e72605af2a110f4f7423d470d56a98e4cfd..a0c3b53d5e14fcb0f88cecf4b85e08d9b691fa4c 100644 --- a/test/java/util/concurrent/ThreadPoolExecutor/ScheduledTickleService.java +++ b/test/java/util/concurrent/ThreadPoolExecutor/ScheduledTickleService.java @@ -37,10 +37,10 @@ public class ScheduledTickleService { // We get intermittent ClassCastException if greater than 1 // because of calls to compareTo - private final static int concurrency = 2; + private static final int concurrency = 2; // Record when tasks are done - public final static CountDownLatch done = new CountDownLatch(concurrency); + public static final CountDownLatch done = new CountDownLatch(concurrency); public static void realMain(String... args) throws InterruptedException { // our tickle service diff --git a/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java b/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java index b2a8313893cf8ec08ee9e4ef1b332369f25814f7..04b08ef6f379749774cede4c88164a4811d7039c 100644 --- a/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java +++ b/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java @@ -40,7 +40,7 @@ public class ShutdownNowExecuteRace { static volatile boolean quit = false; static volatile ThreadPoolExecutor pool = null; - final static Runnable sleeper = new Runnable() { public void run() { + static final Runnable sleeper = new Runnable() { public void run() { final long ONE_HOUR = 1000L * 60L * 60L; try { Thread.sleep(ONE_HOUR); } catch (InterruptedException ie) {} @@ -81,14 +81,14 @@ public class ShutdownNowExecuteRace { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + private abstract static class Fun {abstract void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } catch (Throwable t) { if (k.isAssignableFrom(t.getClass())) pass(); else unexpected(t);}} - private static abstract class CheckedThread extends Thread { + private abstract static class CheckedThread extends Thread { abstract void realRun() throws Throwable; public void run() { try {realRun();} catch (Throwable t) {unexpected(t);}}} diff --git a/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java b/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java index 6ff46c95c6bf0f3bf9c0248bb405e82bc160f033..534bf59f52ef9613584f4070a4c42d76bdc3d065 100644 --- a/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java +++ b/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java @@ -35,7 +35,7 @@ import java.util.concurrent.*; import java.util.concurrent.atomic.*; public class ThrowingTasks { - final static Random rnd = new Random(); + static final Random rnd = new Random(); @SuppressWarnings("serial") static class UncaughtExceptions @@ -65,16 +65,16 @@ public class ThrowingTasks { } } - final static UncaughtExceptions uncaughtExceptions + static final UncaughtExceptions uncaughtExceptions = new UncaughtExceptions(); - final static UncaughtExceptionsTable uncaughtExceptionsTable + static final UncaughtExceptionsTable uncaughtExceptionsTable = new UncaughtExceptionsTable(); - final static AtomicLong totalUncaughtExceptions + static final AtomicLong totalUncaughtExceptions = new AtomicLong(0); - final static CountDownLatch uncaughtExceptionsLatch + static final CountDownLatch uncaughtExceptionsLatch = new CountDownLatch(24); - final static Thread.UncaughtExceptionHandler handler + static final Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { check(! Thread.currentThread().isInterrupted()); @@ -84,19 +84,19 @@ public class ThrowingTasks { uncaughtExceptionsLatch.countDown(); }}; - final static ThreadGroup tg = new ThreadGroup("Flaky"); + static final ThreadGroup tg = new ThreadGroup("Flaky"); - final static ThreadFactory tf = new ThreadFactory() { + static final ThreadFactory tf = new ThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(tg, r); t.setUncaughtExceptionHandler(handler); return t; }}; - final static RuntimeException rte = new RuntimeException(); - final static Error error = new Error(); - final static Throwable weird = new Throwable(); - final static Exception checkedException = new Exception(); + static final RuntimeException rte = new RuntimeException(); + static final Error error = new Error(); + static final Throwable weird = new Throwable(); + static final Exception checkedException = new Exception(); static class Thrower implements Runnable { Throwable t; @@ -105,13 +105,13 @@ public class ThrowingTasks { public void run() { if (t != null) Thread.currentThread().stop(t); } } - final static Thrower noThrower = new Thrower(null); - final static Thrower rteThrower = new Thrower(rte); - final static Thrower errorThrower = new Thrower(error); - final static Thrower weirdThrower = new Thrower(weird); - final static Thrower checkedThrower = new Thrower(checkedException); + static final Thrower noThrower = new Thrower(null); + static final Thrower rteThrower = new Thrower(rte); + static final Thrower errorThrower = new Thrower(error); + static final Thrower weirdThrower = new Thrower(weird); + static final Thrower checkedThrower = new Thrower(checkedException); - final static List throwers = Arrays.asList( + static final List throwers = Arrays.asList( noThrower, rteThrower, errorThrower, weirdThrower, checkedThrower); static class Flaky implements Runnable { diff --git a/test/java/util/concurrent/atomic/VMSupportsCS8.java b/test/java/util/concurrent/atomic/VMSupportsCS8.java index 09c648c3fca35ef96abdb92a0a839504aabf423b..72ad18a9a3060599ae69b3564354aade09bee3c6 100644 --- a/test/java/util/concurrent/atomic/VMSupportsCS8.java +++ b/test/java/util/concurrent/atomic/VMSupportsCS8.java @@ -24,6 +24,8 @@ /* * @test * @bug 4992443 4994819 + * @compile -source 1.5 VMSupportsCS8.java + * @run main VMSupportsCS8 * @summary Checks that the value of VMSupportsCS8 matches system properties. */ diff --git a/test/java/util/concurrent/locks/Lock/FlakyMutex.java b/test/java/util/concurrent/locks/Lock/FlakyMutex.java index 5d4fc70460d6e59ac212c8a7ca600ebb6c1c905f..acee4b9826098ac05fb46bf615cd0d2e17690455 100644 --- a/test/java/util/concurrent/locks/Lock/FlakyMutex.java +++ b/test/java/util/concurrent/locks/Lock/FlakyMutex.java @@ -75,10 +75,10 @@ public class FlakyMutex implements Lock { catch (Throwable t) { checkThrowable(t); } } - try { check (! m.tryLock()); } + try { check(! m.tryLock()); } catch (Throwable t) { checkThrowable(t); } - try { check (! m.tryLock(1, TimeUnit.MICROSECONDS)); } + try { check(! m.tryLock(1, TimeUnit.MICROSECONDS)); } catch (Throwable t) { checkThrowable(t); } m.unlock(); diff --git a/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java b/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java index 5fd884ad33c7652070e2ee132cd0ce9804d9275f..4f00f19abfd96b19c8a8cc02fec6c66b06c11f9c 100644 --- a/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java +++ b/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java @@ -64,7 +64,7 @@ public class TimedAcquireLeak { return outputOf(new InputStreamReader(is, "UTF-8")); } - final static ExecutorService drainers = Executors.newFixedThreadPool(12); + static final ExecutorService drainers = Executors.newFixedThreadPool(12); static Future futureOutputOf(final InputStream is) { return drainers.submit( new Callable() { public String call() throws IOException { diff --git a/test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java b/test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java index fc769df409294cf59bc27c1f39db6208989b821f..3f7667c247a15c69964fb97f8b17638296383292 100644 --- a/test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java +++ b/test/java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java @@ -34,7 +34,7 @@ /* * @test * @bug 4486658 - * @compile CancelledLockLoops.java + * @compile -source 1.5 CancelledLockLoops.java * @run main/timeout=2800 CancelledLockLoops * @summary tests lockInterruptibly. * Checks for responsiveness of locks to interrupts. Runs under that @@ -64,7 +64,7 @@ public final class CancelledLockLoops { try { new ReentrantLockLoop(i).test(); } - catch(BrokenBarrierException bb) { + catch (BrokenBarrierException bb) { // OK, ignore } Thread.sleep(TIMEOUT); diff --git a/test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java b/test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java index 88b2f2d00b14f31078110773bbb4a796c4accb98..8682e24dbab8b8af2c4cb1236f17af3e8b10763a 100644 --- a/test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java +++ b/test/java/util/concurrent/locks/ReentrantLock/LockOncePerThreadLoops.java @@ -34,7 +34,7 @@ /* * @test * @bug 4486658 - * @compile LockOncePerThreadLoops.java + * @compile -source 1.5 LockOncePerThreadLoops.java * @run main/timeout=15000 LockOncePerThreadLoops * @summary Checks for missed signals by locking and unlocking each of an array of locks once per thread */ diff --git a/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java b/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java index d3dd5b4a5ef182500f5f8c375c941c01e96bb1a9..6b65b8b2d4aa5b0eec43287030d252a71b89e0cd 100644 --- a/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java +++ b/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java @@ -78,9 +78,9 @@ class LoopHelpers { * Basically same as java.util.Random. */ public static class SimpleRandom { - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; static final AtomicLong seq = new AtomicLong(1); private long seed = System.nanoTime() + seq.getAndIncrement(); diff --git a/test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java b/test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java index ac85bba4c3f646393973713c5036fb0ee6b49cbd..db7d5af61dc1ab205ac4c8cff69c0af15a23022a 100644 --- a/test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java +++ b/test/java/util/concurrent/locks/ReentrantLock/SimpleReentrantLockLoops.java @@ -34,7 +34,7 @@ /* * @test * @bug 4486658 - * @compile SimpleReentrantLockLoops.java + * @compile -source 1.5 SimpleReentrantLockLoops.java * @run main/timeout=4500 SimpleReentrantLockLoops * @summary multiple threads using a single lock */ diff --git a/test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java b/test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java index 0a90bebc352fb264738efff6983ba40b0938593f..3c20867531a976a8cacde8747b1ca34b9ec1ae96 100644 --- a/test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java +++ b/test/java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java @@ -34,6 +34,8 @@ /* * @test * @bug 4486658 5031862 + * @compile -source 1.5 TimeoutLockLoops.java + * @run main TimeoutLockLoops * @summary Checks for responsiveness of locks to timeouts. * Runs under the assumption that ITERS computations require more than * TIMEOUT msecs to complete, which seems to be a safe assumption for diff --git a/test/java/util/concurrent/locks/ReentrantReadWriteLock/Bug6571733.java b/test/java/util/concurrent/locks/ReentrantReadWriteLock/Bug6571733.java index c63e7a30c77371ea97820c28f1516d6cad815c40..0a65d352a90846bdcfb4e6088af636dafe48f599 100644 --- a/test/java/util/concurrent/locks/ReentrantReadWriteLock/Bug6571733.java +++ b/test/java/util/concurrent/locks/ReentrantReadWriteLock/Bug6571733.java @@ -45,7 +45,7 @@ public class Bug6571733 { Thread thread = new Thread() { public void run() { try { - check (! lock.writeLock().tryLock(0, TimeUnit.DAYS)); + check(! lock.writeLock().tryLock(0, TimeUnit.DAYS)); lock.readLock().lock(); lock.readLock().unlock(); diff --git a/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java b/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java index d3dd5b4a5ef182500f5f8c375c941c01e96bb1a9..6b65b8b2d4aa5b0eec43287030d252a71b89e0cd 100644 --- a/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java +++ b/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java @@ -78,9 +78,9 @@ class LoopHelpers { * Basically same as java.util.Random. */ public static class SimpleRandom { - private final static long multiplier = 0x5DEECE66DL; - private final static long addend = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; static final AtomicLong seq = new AtomicLong(1); private long seed = System.nanoTime() + seq.getAndIncrement(); diff --git a/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java b/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java index ce6651fbb2df6035e35e3d19662292f61512fe71..a8e47e5a25edf9dfeca3ca70c169c6223931c289 100644 --- a/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java +++ b/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java @@ -34,7 +34,7 @@ /* * @test * @bug 4486658 - * @compile MapLoops.java + * @compile -source 1.5 MapLoops.java * @run main/timeout=4700 MapLoops * @summary Exercise multithreaded maps, by default ConcurrentHashMap. * Multithreaded hash table test. Each thread does a random walk @@ -65,7 +65,7 @@ public class MapLoops { if (args.length > 0) { try { mapClass = Class.forName(args[0]); - } catch(ClassNotFoundException e) { + } catch (ClassNotFoundException e) { throw new RuntimeException("Class " + args[0] + " not found."); } } diff --git a/test/java/util/concurrent/locks/ReentrantReadWriteLock/RWMap.java b/test/java/util/concurrent/locks/ReentrantReadWriteLock/RWMap.java index 8c5121e536a2921856a5fb878b28a7ab0062b2d8..53f63d6e33c01dca54eec675ddc62a5ff86e6749 100644 --- a/test/java/util/concurrent/locks/ReentrantReadWriteLock/RWMap.java +++ b/test/java/util/concurrent/locks/ReentrantReadWriteLock/RWMap.java @@ -57,21 +57,33 @@ public class RWMap implements Map { } public int size() { - rwl.readLock().lock(); try {return m.size();} finally { rwl.readLock().unlock(); } + rwl.readLock().lock(); + try { return m.size(); } + finally { rwl.readLock().unlock(); } } - public boolean isEmpty(){ - rwl.readLock().lock(); try {return m.isEmpty();} finally { rwl.readLock().unlock(); } + + public boolean isEmpty() { + rwl.readLock().lock(); + try { return m.isEmpty(); } + finally { rwl.readLock().unlock(); } } public Object get(Object key) { - rwl.readLock().lock(); try {return m.get(key);} finally { rwl.readLock().unlock(); } + rwl.readLock().lock(); + try { return m.get(key); } + finally { rwl.readLock().unlock(); } } public boolean containsKey(Object key) { - rwl.readLock().lock(); try {return m.containsKey(key);} finally { rwl.readLock().unlock(); } + rwl.readLock().lock(); + try { return m.containsKey(key); } + finally { rwl.readLock().unlock(); } } - public boolean containsValue(Object value){ - rwl.readLock().lock(); try {return m.containsValue(value);} finally { rwl.readLock().unlock(); } + + public boolean containsValue(Object value) { + rwl.readLock().lock(); + try { return m.containsValue(value); } + finally { rwl.readLock().unlock(); } } @@ -88,28 +100,45 @@ public class RWMap implements Map { } public boolean equals(Object o) { - rwl.readLock().lock(); try {return m.equals(o);} finally { rwl.readLock().unlock(); } + rwl.readLock().lock(); + try { return m.equals(o); } + finally { rwl.readLock().unlock(); } } + public int hashCode() { - rwl.readLock().lock(); try {return m.hashCode();} finally { rwl.readLock().unlock(); } + rwl.readLock().lock(); + try { return m.hashCode(); } + finally { rwl.readLock().unlock(); } } + public String toString() { - rwl.readLock().lock(); try {return m.toString();} finally { rwl.readLock().unlock(); } + rwl.readLock().lock(); + try { return m.toString(); } + finally { rwl.readLock().unlock(); } } - - public Object put(Object key, Object value) { - rwl.writeLock().lock(); try {return m.put(key, value);} finally { rwl.writeLock().unlock(); } + rwl.writeLock().lock(); + try { return m.put(key, value); } + finally { rwl.writeLock().unlock(); } } + public Object remove(Object key) { - rwl.writeLock().lock(); try {return m.remove(key);} finally { rwl.writeLock().unlock(); } + rwl.writeLock().lock(); + try { return m.remove(key); } + finally { rwl.writeLock().unlock(); } } + public void putAll(Map map) { - rwl.writeLock().lock(); try {m.putAll(map);} finally { rwl.writeLock().unlock(); } + rwl.writeLock().lock(); + try { m.putAll(map); } + finally { rwl.writeLock().unlock(); } } + public void clear() { - rwl.writeLock().lock(); try {m.clear();} finally { rwl.writeLock().unlock(); } + rwl.writeLock().lock(); + try { m.clear(); } + finally { rwl.writeLock().unlock(); } } }