Initial load
diff --git a/test/java/util/Collections/AddAll.java b/test/java/util/Collections/AddAll.java
new file mode 100644
index 0000000..ef66b00
--- /dev/null
+++ b/test/java/util/Collections/AddAll.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4822887
+ * @summary Basic test for Collections.addAll
+ * @author  Josh Bloch
+ *
+ * @compile -source 1.5 AddAll.java
+ * @run main AddAll
+ */
+
+import java.util.*;
+
+public class AddAll {
+    final static int N = 100;
+    public static void main(String args[]) {
+        test(new ArrayList<Integer>());
+        test(new LinkedList<Integer>());
+        test(new HashSet<Integer>());
+        test(new LinkedHashSet<Integer>());
+    }
+
+    private static Random rnd = new Random();
+
+    static void test(Collection<Integer> c) {
+        int x = 0;
+        for (int i = 0; i < N; i++) {
+            int rangeLen = rnd.nextInt(10);
+            if (Collections.addAll(c, range(x, x + rangeLen)) !=
+                (rangeLen != 0))
+                throw new RuntimeException("" + rangeLen);
+            x += rangeLen;
+        }
+        if (c instanceof List) {
+            if (!c.equals(Arrays.asList(range(0, x))))
+                throw new RuntimeException(x +": "+c);
+        } else {
+            if (!c.equals(new HashSet<Integer>(Arrays.asList(range(0, x)))))
+                throw new RuntimeException(x +": "+c);
+        }
+    }
+
+    private static Integer[] range(int from, int to) {
+        Integer[] result = new Integer[to - from];
+        for (int i = from, j=0; i < to; i++, j++)
+            result[j] = new Integer(i);
+        return result;
+    }
+}
diff --git a/test/java/util/Collections/AsLifoQueue.java b/test/java/util/Collections/AsLifoQueue.java
new file mode 100644
index 0000000..f452d30
--- /dev/null
+++ b/test/java/util/Collections/AsLifoQueue.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6301085 6192552 6365601
+ * @summary Basic tests for asLifoQueue
+ * @author  Martin Buchholz
+ */
+
+import java.util.*;
+import java.util.concurrent.*;
+
+public class AsLifoQueue {
+
+    private static void realMain(String[] args) throws Throwable {
+        try {
+            Deque<String> deq = new ArrayDeque<String>();
+            check(deq.addAll(Arrays.asList("b", "a", "c")));
+            equal(deq.toString(), "[b, a, c]");
+            check(deq.add("d"));
+            equal(deq.toString(), "[b, a, c, d]");
+            Queue<String> q = Collections.asLifoQueue(deq);
+            check(q.add("e"));
+            equal(deq.toString(),"[e, b, a, c, d]");
+        } catch (Throwable t) { unexpected(t); }
+
+        // Inspired by an excellent bug report by Jason Mehrens
+        try {
+            final Queue<String> q =
+                Collections.asLifoQueue(new LinkedBlockingDeque<String>(3));
+            check(q.isEmpty()); equal(q.size(), 0);
+            check(q.add("a")); check(! q.isEmpty()); equal(q.size(), 1);
+            check(q.offer("b"));
+            check(q.add("c"));
+            equal(q.size(), 3);
+            check(! q.offer("d"));
+            equal(q.size(), 3);
+            THROWS(IllegalStateException.class,
+                   new Fun(){void f(){ q.add("d"); }});
+            equal(q.size(), 3);
+            equal(q.toString(), "[c, b, a]");
+            equal(q.peek(), "c");
+            equal(q.element(), "c");
+            equal(q.remove(), "c");
+            equal(q.poll(), "b");
+            equal(q.peek(), "a");
+            equal(q.remove(), "a");
+            THROWS(NoSuchElementException.class,
+                   new Fun(){void f(){ q.remove(); }});
+            equal(q.poll(), null);
+            check(q.isEmpty());
+            equal(q.size(), 0);
+        } catch (Throwable t) { unexpected(t); }
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    static volatile int passed = 0, failed = 0;
+    static void pass() {passed++;}
+    static void fail() {failed++; Thread.dumpStack();}
+    static void fail(String msg) {System.out.println(msg); fail();}
+    static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    static void check(boolean cond) {if (cond) pass(); else fail();}
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        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; }
+    private static void THROWS(Class<? extends Throwable> 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);}}
+}
diff --git a/test/java/util/Collections/BigBinarySearch.java b/test/java/util/Collections/BigBinarySearch.java
new file mode 100644
index 0000000..f166ed5
--- /dev/null
+++ b/test/java/util/Collections/BigBinarySearch.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5045582
+ * @summary binarySearch of Collections larger than 1<<30
+ * @author Martin Buchholz
+ */
+
+import java.util.*;
+
+public class BigBinarySearch {
+
+    // Allows creation of very "big" collections without using too
+    // many real resources
+    static class SparseIntegerList
+        extends AbstractList<Integer>
+        implements RandomAccess
+    {
+        private Map<Integer,Integer> m = new HashMap<Integer,Integer>();
+
+        public Integer get(int i) {
+            if (i < 0) throw new IndexOutOfBoundsException(""+i);
+            Integer v = m.get(i);
+            return (v == null) ? Integer.valueOf(0) : v;
+        }
+
+        public int size() {
+            return Collections.max(m.keySet()) + 1;
+        }
+
+        public Integer set(int i, Integer v) {
+            if (i < 0) throw new IndexOutOfBoundsException(""+i);
+            Integer ret = get(i);
+            if (v == 0)
+                m.remove(i);
+            else
+                m.put(i, v);
+            return ret;
+        }
+    }
+
+    /** Check that binarySearch finds an element where we got it */
+    private static void checkBinarySearch(List<Integer> l, int i) {
+        try { equal(i, Collections.binarySearch(l, l.get(i))); }
+        catch (Throwable t) { unexpected(t); }
+    }
+
+    /** Check that binarySearch finds an element where we got it */
+    private static void checkBinarySearch(List<Integer> l, int i,
+                                          Comparator<Integer> comparator) {
+        try { equal(i, Collections.binarySearch(l, l.get(i), comparator)); }
+        catch (Throwable t) { unexpected(t); }
+    }
+
+    private static void realMain(String[] args) throws Throwable {
+        final int n = (1<<30) + 47;
+
+        System.out.println("binarySearch(List<Integer>, Integer)");
+        List<Integer> big = new SparseIntegerList();
+        big.set(  0, -44);
+        big.set(  1, -43);
+        big.set(n-2,  43);
+        big.set(n-1,  44);
+        int[] ints = { 0, 1, n-2, n-1 };
+        Comparator<Integer> reverse = Collections.reverseOrder();
+        Comparator<Integer> natural = Collections.reverseOrder(reverse);
+
+        for (int i : ints) {
+            checkBinarySearch(big, i);
+            checkBinarySearch(big, i, null);
+            checkBinarySearch(big, i, natural);
+        }
+        for (int i : ints)
+            big.set(i, - big.get(i));
+        for (int i : ints)
+            checkBinarySearch(big, i, reverse);
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    static volatile int passed = 0, failed = 0;
+    static void pass() {passed++;}
+    static void fail() {failed++; Thread.dumpStack();}
+    static void fail(String msg) {System.out.println(msg); fail();}
+    static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    static void check(boolean cond) {if (cond) pass(); else fail();}
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        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");}
+}
diff --git a/test/java/util/Collections/BinarySearchNullComparator.java b/test/java/util/Collections/BinarySearchNullComparator.java
new file mode 100644
index 0000000..4564e4a
--- /dev/null
+++ b/test/java/util/Collections/BinarySearchNullComparator.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2001-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4528331 5006032
+ * @summary Test Collections.binarySearch() with a null comparator
+ */
+
+
+import java.util.*;
+
+public class BinarySearchNullComparator {
+    public static void main (String args[]) throws Exception {
+        List list = Arrays.asList(new String[] {"I", "Love", "You"});
+
+        int result = Collections.binarySearch(list, "You", null);
+        if (result != 2)
+            throw new Exception("Result: " + result);
+    }
+}
diff --git a/test/java/util/Collections/CheckedIdentityMap.java b/test/java/util/Collections/CheckedIdentityMap.java
new file mode 100644
index 0000000..4a2e216
--- /dev/null
+++ b/test/java/util/Collections/CheckedIdentityMap.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6585904
+ * @summary Checked collections with underlying maps with identity comparisons
+ */
+
+import java.util.*;
+import static java.util.Collections.*;
+
+public class CheckedIdentityMap {
+    void test(String[] args) throws Throwable {
+        Map<Integer, Integer> m1 = checkedMap(
+            new IdentityHashMap<Integer, Integer>(),
+            Integer.class, Integer.class);
+        Map<Integer, Integer> m2 = checkedMap(
+            new IdentityHashMap<Integer, Integer>(),
+            Integer.class, Integer.class);
+        m1.put(new Integer(1), new Integer(1));
+        m2.put(new Integer(1), new Integer(1));
+
+        Map.Entry<Integer, Integer> e1 = m1.entrySet().iterator().next();
+        Map.Entry<Integer, Integer> e2 = m2.entrySet().iterator().next();
+        check(! e1.equals(e2));
+        check(e1.hashCode() == hashCode(e1));
+        check(e2.hashCode() == hashCode(e2));
+    }
+
+    int hashCode(Map.Entry<?,?> e) {
+        return (System.identityHashCode(e.getKey()) ^
+                System.identityHashCode(e.getValue()));
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    volatile int passed = 0, failed = 0;
+    void pass() {passed++;}
+    void fail() {failed++; Thread.dumpStack();}
+    void fail(String msg) {System.err.println(msg); fail();}
+    void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    void check(boolean cond) {if (cond) pass(); else fail();}
+    void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        new CheckedIdentityMap().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");}
+    abstract class F {abstract void f() throws Throwable;}
+    void THROWS(Class<? extends Throwable> k, F... fs) {
+        for (F f : fs)
+            try {f.f(); fail("Expected " + k.getName() + " not thrown");}
+            catch (Throwable t) {
+                if (k.isAssignableFrom(t.getClass())) pass();
+                else unexpected(t);}}
+    Thread checkedThread(final Runnable r) {
+        return new Thread() {public void run() {
+            try {r.run();} catch (Throwable t) {unexpected(t);}}};}
+}
diff --git a/test/java/util/Collections/CheckedListBash.java b/test/java/util/Collections/CheckedListBash.java
new file mode 100644
index 0000000..64f4358
--- /dev/null
+++ b/test/java/util/Collections/CheckedListBash.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4904067
+ * @summary Unit test for Collections.checkedList
+ * @author  Josh Bloch
+ */
+
+import java.util.*;
+
+public class CheckedListBash {
+    static Random rnd = new Random();
+
+    public static void main(String[] args) {
+        int numItr = 100;
+        int listSize = 100;
+
+        for (int i=0; i<numItr; i++) {
+            List s1 = newList();
+            AddRandoms(s1, listSize);
+
+            List s2 = newList();
+            AddRandoms(s2, listSize);
+
+            List intersection = clone(s1); intersection.retainAll(s2);
+            List diff1 = clone(s1); diff1.removeAll(s2);
+            List diff2 = clone(s2); diff2.removeAll(s1);
+            List union = clone(s1); union.addAll(s2);
+
+            if (diff1.removeAll(diff2))
+                fail("List algebra identity 2 failed");
+            if (diff1.removeAll(intersection))
+                fail("List algebra identity 3 failed");
+            if (diff2.removeAll(diff1))
+                fail("List algebra identity 4 failed");
+            if (diff2.removeAll(intersection))
+                fail("List algebra identity 5 failed");
+            if (intersection.removeAll(diff1))
+                fail("List algebra identity 6 failed");
+            if (intersection.removeAll(diff1))
+                fail("List algebra identity 7 failed");
+
+            intersection.addAll(diff1); intersection.addAll(diff2);
+            if (!(intersection.containsAll(union) &&
+                  union.containsAll(intersection)))
+                fail("List algebra identity 1 failed");
+
+            Iterator e = union.iterator();
+            while (e.hasNext())
+                intersection.remove(e.next());
+            if (!intersection.isEmpty())
+                fail("Copy nonempty after deleting all elements.");
+
+            e = union.iterator();
+            while (e.hasNext()) {
+                Object o = e.next();
+                if (!union.contains(o))
+                    fail("List doesn't contain one of its elements.");
+                e.remove();
+            }
+            if (!union.isEmpty())
+                fail("List nonempty after deleting all elements.");
+
+            s1.clear();
+            if (s1.size() != 0)
+                fail("Clear didn't reduce size to zero.");
+
+            s1.addAll(0, s2);
+            if (!(s1.equals(s2) && s2.equals(s1)))
+                fail("addAll(int, Collection) doesn't work.");
+            // Reverse List
+            for (int j=0, n=s1.size(); j<n; j++)
+                s1.set(j, s1.set(n-j-1, s1.get(j)));
+            // Reverse it again
+            for (int j=0, n=s1.size(); j<n; j++)
+                s1.set(j, s1.set(n-j-1, s1.get(j)));
+            if (!(s1.equals(s2) && s2.equals(s1)))
+                fail("set(int, Object) doesn't work");
+        }
+
+        List s = newList();
+        for (int i=0; i<listSize; i++)
+            s.add(new Integer(i));
+        if (s.size() != listSize)
+            fail("Size of [0..n-1] != n");
+
+        List even = clone(s);
+        Iterator it = even.iterator();
+        while(it.hasNext())
+            if(((Integer)it.next()).intValue() % 2 == 1)
+                it.remove();
+        it = even.iterator();
+        while(it.hasNext())
+            if(((Integer)it.next()).intValue() % 2 == 1)
+                fail("Failed to remove all odd nubmers.");
+
+        List odd = clone(s);
+        for (int i=0; i<(listSize/2); i++)
+            odd.remove(i);
+        for (int i=0; i<(listSize/2); i++)
+            if(((Integer)odd.get(i)).intValue() % 2 != 1)
+                fail("Failed to remove all even nubmers.");
+
+        List all = clone(odd);
+        for (int i=0; i<(listSize/2); i++)
+            all.add(2*i, even.get(i));
+        if (!all.equals(s))
+            fail("Failed to reconstruct ints from odds and evens.");
+
+        all = clone(odd);
+        ListIterator itAll = all.listIterator(all.size());
+        ListIterator itEven = even.listIterator(even.size());
+        while (itEven.hasPrevious()) {
+            itAll.previous();
+            itAll.add(itEven.previous());
+            itAll.previous(); // ???
+        }
+        itAll = all.listIterator();
+        while (itAll.hasNext()) {
+            Integer i = (Integer)itAll.next();
+            itAll.set(new Integer(i.intValue()));
+        }
+        itAll = all.listIterator();
+        it = s.iterator();
+        while(it.hasNext())
+            if(it.next()==itAll.next())
+                fail("Iterator.set failed to change value.");
+        if (!all.equals(s))
+            fail("Failed to reconstruct ints with ListIterator.");
+
+        it = all.listIterator();
+        int i=0;
+        while (it.hasNext()) {
+            Object o = it.next();
+            if (all.indexOf(o) != all.lastIndexOf(o))
+                fail("Apparent duplicate detected.");
+            if (all.subList(i,   all.size()).indexOf(o) != 0 ||
+                all.subList(i+1, all.size()).indexOf(o) != -1)
+                fail("subList/indexOf is screwy.");
+            if (all.subList(0,i+1).lastIndexOf(o) != i)
+                fail("subList/lastIndexOf is screwy.");
+            i++;
+        }
+
+        List l = newList();
+        AddRandoms(l, listSize);
+        Integer[] ia = (Integer[]) l.toArray(new Integer[0]);
+        if (!l.equals(Arrays.asList(ia)))
+            fail("toArray(Object[]) is hosed (1)");
+        ia = new Integer[listSize];
+        Integer[] ib = (Integer[]) l.toArray(ia);
+        if (ia != ib || !l.equals(Arrays.asList(ia)))
+            fail("toArray(Object[]) is hosed (2)");
+        ia = new Integer[listSize+1];
+        ia[listSize] = new Integer(69);
+        ib = (Integer[]) l.toArray(ia);
+        if (ia != ib || ia[listSize] != null
+            || !l.equals(Arrays.asList(ia).subList(0, listSize)))
+            fail("toArray(Object[]) is hosed (3)");
+
+    }
+
+    // Done inefficiently so as to exercise toArray
+    static List clone(List s) {
+        List a = Arrays.asList(s.toArray());
+        if (s.hashCode() != a.hashCode())
+            fail("Incorrect hashCode computation.");
+
+        List clone = newList();
+        clone.addAll(a);
+        if (!s.equals(clone))
+            fail("List not equal to copy.");
+        if (!s.containsAll(clone))
+            fail("List does not contain copy.");
+        if (!clone.containsAll(s))
+            fail("Copy does not contain list.");
+
+        return clone;
+    }
+
+    static List newList() {
+        List s =  Collections.checkedList(new ArrayList(), Integer.class);
+        if (!s.isEmpty())
+            fail("New instance non empty.");
+        return s;
+    }
+
+    static void AddRandoms(List s, int n) {
+        for (int i=0; i<n; i++) {
+            int r = rnd.nextInt() % n;
+            Integer e = new Integer(r < 0 ? -r : r);
+
+            int preSize = s.size();
+            if (!s.add(e))
+                fail ("Add failed.");
+            int postSize = s.size();
+            if (postSize-preSize != 1)
+                fail ("Add didn't increase size by 1.");
+        }
+    }
+
+    static void fail(String s) {
+        throw new RuntimeException(s);
+    }
+}
diff --git a/test/java/util/Collections/CheckedMapBash.java b/test/java/util/Collections/CheckedMapBash.java
new file mode 100644
index 0000000..b236941
--- /dev/null
+++ b/test/java/util/Collections/CheckedMapBash.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4904067 5023830
+ * @summary Unit test for Collections.checkedMap
+ * @author  Josh Bloch
+ */
+
+import java.util.*;
+
+public class CheckedMapBash {
+    static Random rnd = new Random();
+    static Object nil = new Integer(0);
+
+    public static void main(String[] args) {
+        int numItr = 100;
+        int mapSize = 100;
+
+        // Linked List test
+        for (int i=0; i<numItr; i++) {
+            Map m = newMap();
+            Object head = nil;
+
+            for (int j=0; j<mapSize; j++) {
+                Object newHead;
+                do {
+                    newHead = new Integer(rnd.nextInt());
+                } while (m.containsKey(newHead));
+                m.put(newHead, head);
+                head = newHead;
+            }
+            if (m.size() != mapSize)
+                fail("Size not as expected.");
+
+            {
+                HashMap hm = new HashMap(m);
+                if (! (hm.hashCode() == m.hashCode() &&
+                       hm.entrySet().hashCode() == m.entrySet().hashCode() &&
+                       hm.keySet().hashCode() == m.keySet().hashCode()))
+                    fail("Incorrect hashCode computation.");
+
+                if (! (hm.equals(m) &&
+                       hm.entrySet().equals(m.entrySet()) &&
+                       hm.keySet().equals(m.keySet()) &&
+                       m.equals(hm) &&
+                       m.entrySet().equals(hm.entrySet()) &&
+                       m.keySet().equals(hm.keySet())))
+                    fail("Incorrect equals computation.");
+            }
+
+            Map m2 = newMap(); m2.putAll(m);
+            m2.values().removeAll(m.keySet());
+            if (m2.size()!= 1 || !m2.containsValue(nil))
+                fail("Collection views test failed.");
+
+            int j=0;
+            while (head != nil) {
+                if (!m.containsKey(head))
+                    fail("Linked list doesn't contain a link.");
+                Object newHead = m.get(head);
+                if (newHead == null)
+                    fail("Could not retrieve a link.");
+                m.remove(head);
+                head = newHead;
+                j++;
+            }
+            if (!m.isEmpty())
+                fail("Map nonempty after removing all links.");
+            if (j != mapSize)
+                fail("Linked list size not as expected.");
+        }
+
+        Map m = newMap();
+        for (int i=0; i<mapSize; i++)
+            if (m.put(new Integer(i), new Integer(2*i)) != null)
+                fail("put returns a non-null value erroenously.");
+        for (int i=0; i<2*mapSize; i++)
+            if (m.containsValue(new Integer(i)) != (i%2==0))
+                fail("contains value "+i);
+        if (m.put(nil, nil) == null)
+            fail("put returns a null value erroenously.");
+        Map m2 = newMap(); m2.putAll(m);
+        if (!m.equals(m2))
+            fail("Clone not equal to original. (1)");
+        if (!m2.equals(m))
+            fail("Clone not equal to original. (2)");
+        Set s = m.entrySet(), s2 = m2.entrySet();
+        if (!s.equals(s2))
+            fail("Clone not equal to original. (3)");
+        if (!s2.equals(s))
+            fail("Clone not equal to original. (4)");
+        if (!s.containsAll(s2))
+            fail("Original doesn't contain clone!");
+        if (!s2.containsAll(s))
+            fail("Clone doesn't contain original!");
+
+        s2.removeAll(s);
+        if (!m2.isEmpty())
+            fail("entrySet().removeAll failed.");
+
+        m2.putAll(m);
+        m2.clear();
+        if (!m2.isEmpty())
+            fail("clear failed.");
+
+        Iterator i = m.entrySet().iterator();
+        while(i.hasNext()) {
+            i.next();
+            i.remove();
+        }
+        if (!m.isEmpty())
+            fail("Iterator.remove() failed");
+    }
+
+    static Map newMap() {
+        Map m = Collections.checkedMap(new HashMap(),
+                                       Integer.class, Integer.class);
+
+        if (!m.isEmpty())
+            fail("New instance non empty.");
+        return m;
+    }
+
+    static void fail(String s) {
+        throw new RuntimeException(s);
+    }
+}
diff --git a/test/java/util/Collections/CheckedNull.java b/test/java/util/Collections/CheckedNull.java
new file mode 100644
index 0000000..6bb19e7
--- /dev/null
+++ b/test/java/util/Collections/CheckedNull.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6409434
+ * @summary Test behavior of nulls in checked collections
+ */
+
+import java.util.*;
+import static java.util.Collections.*;
+
+@SuppressWarnings({"unchecked","serial"})
+public class CheckedNull {
+
+    void test(String[] args) throws Throwable {
+        testCollection(Collections.checkedCollection(
+                           new ArrayList<String>(), String.class));
+        testCollection(Collections.checkedList(
+                           new ArrayList<String>(), String.class));
+        testCollection(Collections.checkedSet(
+                           new HashSet<String>(), String.class));
+
+        final Comparator nullLow = new Comparator() {
+                public int compare(Object x, Object y) {
+                    return x == y ?  0 :
+                        x == null ? -1 :
+                        y == null ?  1 :
+                        ((Comparable)x).compareTo(y); }};
+        testCollection(Collections.checkedSortedSet(
+                           new TreeSet<String>(nullLow), String.class));
+
+        testMap(Collections.checkedMap(
+                    new HashMap<String, String>(),
+                    String.class, String.class));;
+    }
+
+    ClassCastException cce(F f) {
+        try { f.f(); fail(); return null; }
+        catch (ClassCastException cce) { pass(); return cce; }
+        catch (Throwable t) { unexpected(t); return null; }
+    }
+
+    void equalCCE(F ... fs) {
+        String detailMessage = null;
+        for (F f : fs)
+            if (detailMessage == null)
+                detailMessage = cce(f).getMessage();
+            else
+                equal(detailMessage, cce(f).getMessage());
+    }
+
+    void add(Collection c, Object o) {
+        int s = c.size();
+        check(! c.contains(o));
+        check(c.add(o));
+        check(c.contains(o));
+        equal(c.size(), s+1);
+        check(c.remove(o));
+        check(! c.contains(o));
+        check(c.addAll(singleton(o)));
+        check(c.contains(o));
+        equal(c.size(), s+1);
+        check(c.remove(o));
+        equal(c.size(), s);
+    }
+
+    void testCollection(final Collection c) {
+        try {
+            check(c.isEmpty());
+            add(c, null);
+            add(c, "foo");
+
+            check(c.add("bar"));
+            add(c, null);
+            add(c, "foo");
+
+            equalCCE(
+                new F(){void f(){ c.add(1); }},
+                new F(){void f(){ c.addAll(singleton(1)); }});
+
+        } catch (Throwable t) { unexpected(t); }
+    }
+
+    void put(Map m, Object k, Object v) {
+        int s = m.size();
+        check(! m.containsKey(k));
+        check(! m.containsValue(v));
+        equal(null, m.put(k, v));
+        check(m.containsKey(k));
+        check(m.containsValue(v));
+        equal(m.size(), s+1);
+        equal(v, m.remove(k));
+        check(! m.containsKey(k));
+        check(! m.containsValue(v));
+        m.putAll(singletonMap(k,v));
+        check(m.containsKey(k));
+        check(m.containsValue(v));
+        equal(m.size(), s+1);
+        equal(v,m.remove(k));
+        equal(m.size(), s);
+    }
+
+    void testMap(final Map m) {
+        try {
+            check(m.isEmpty());
+
+            put(m, "foo", null);
+            put(m, null, "foo");
+            put(m, null, null);
+            put(m, "foo", "bar");
+
+            m.put("a", "b");
+
+            put(m, "foo", null);
+            put(m, null, "foo");
+            put(m, null, null);
+            put(m, "foo", "bar");
+
+            equalCCE(
+                new F(){void f(){ m.put(1, "foo"); }},
+                new F(){void f(){ m.putAll(singletonMap(1, "foo")); }});
+
+            final Collection cheater = new ArrayList() {
+                    public boolean contains(Object o) {
+                        if (o instanceof Map.Entry)
+                            ((Map.Entry)o).setValue(1);
+                        return false; }};
+
+            equalCCE(
+                new F(){void f(){ m.put("foo", 1); }},
+                new F(){void f(){ m.putAll(singletonMap("foo", 1)); }},
+                new F(){void f(){
+                    ((Map.Entry)m.entrySet().iterator().next()).setValue(1); }},
+                new F(){void f(){
+                    m.entrySet().removeAll(cheater);}},
+                new F(){void f(){
+                    m.entrySet().retainAll(cheater);}});
+
+            equalCCE(
+                new F(){void f(){ m.put(3, 1); }},
+                new F(){void f(){ m.putAll(singletonMap(3, 1)); }});
+
+            equal(m.size(), 1);
+            equal(m.keySet(), singleton("a"));
+            equal(m.entrySet(),
+                  singleton(new AbstractMap.SimpleImmutableEntry("a","b")));
+
+        } catch (Throwable t) { unexpected(t); }
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    volatile int passed = 0, failed = 0;
+    void pass() {passed++;}
+    void fail() {failed++; Thread.dumpStack();}
+    void fail(String msg) {System.err.println(msg); fail();}
+    void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    void check(boolean cond) {if (cond) pass(); else fail();}
+    void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        new CheckedNull().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");}
+    abstract class F {abstract void f() throws Throwable;}
+}
diff --git a/test/java/util/Collections/CheckedSetBash.java b/test/java/util/Collections/CheckedSetBash.java
new file mode 100644
index 0000000..7e6ebbf
--- /dev/null
+++ b/test/java/util/Collections/CheckedSetBash.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4904067
+ * @summary Unit test for Collections.checkedSet
+ * @author  Josh Bloch
+ */
+
+import java.util.*;
+
+public class CheckedSetBash {
+    static Random rnd = new Random();
+
+    public static void main(String[] args) {
+        int numItr = 100;
+        int setSize = 100;
+
+        for (int i=0; i<numItr; i++) {
+            Set s1 = newSet();
+            AddRandoms(s1, setSize);
+
+            Set s2 = newSet();
+            AddRandoms(s2, setSize);
+
+            Set intersection = clone(s1);
+            intersection.retainAll(s2);
+            Set diff1 = clone(s1); diff1.removeAll(s2);
+            Set diff2 = clone(s2); diff2.removeAll(s1);
+            Set union = clone(s1); union.addAll(s2);
+
+            if (diff1.removeAll(diff2))
+                fail("Set algebra identity 2 failed");
+            if (diff1.removeAll(intersection))
+                fail("Set algebra identity 3 failed");
+            if (diff2.removeAll(diff1))
+                fail("Set algebra identity 4 failed");
+            if (diff2.removeAll(intersection))
+                fail("Set algebra identity 5 failed");
+            if (intersection.removeAll(diff1))
+                fail("Set algebra identity 6 failed");
+            if (intersection.removeAll(diff1))
+                fail("Set algebra identity 7 failed");
+
+            intersection.addAll(diff1); intersection.addAll(diff2);
+            if (!intersection.equals(union))
+                fail("Set algebra identity 1 failed");
+
+            if (new HashSet(union).hashCode() != union.hashCode())
+                fail("Incorrect hashCode computation.");
+
+            Iterator e = union.iterator();
+            while (e.hasNext())
+                if (!intersection.remove(e.next()))
+                    fail("Couldn't remove element from copy.");
+            if (!intersection.isEmpty())
+                fail("Copy nonempty after deleting all elements.");
+
+            e = union.iterator();
+            while (e.hasNext()) {
+                Object o = e.next();
+                if (!union.contains(o))
+                    fail("Set doesn't contain one of its elements.");
+                e.remove();
+                if (union.contains(o))
+                    fail("Set contains element after deletion.");
+            }
+            if (!union.isEmpty())
+                fail("Set nonempty after deleting all elements.");
+
+            s1.clear();
+            if (!s1.isEmpty())
+                fail("Set nonempty after clear.");
+        }
+    }
+
+    // Done inefficiently so as to exercise toArray
+    static Set clone(Set s) {
+        Set clone = newSet();
+        List arrayList = Arrays.asList(s.toArray());
+        clone.addAll(arrayList);
+        if (!s.equals(clone))
+            fail("Set not equal to copy.");
+        if (!s.containsAll(clone))
+            fail("Set does not contain copy.");
+        if (!clone.containsAll(s))
+            fail("Copy does not contain set.");
+        return clone;
+    }
+
+    static Set newSet() {
+        Set s = Collections.checkedSet(new HashSet(), Integer.class);
+        if (!s.isEmpty())
+            fail("New instance non empty.");
+        return s;
+    }
+
+    static void AddRandoms(Set s, int n) {
+        for (int i=0; i<n; i++) {
+            int r = rnd.nextInt() % n;
+            Integer e = new Integer(r < 0 ? -r : r);
+
+            int preSize = s.size();
+            boolean prePresent = s.contains(e);
+            boolean added = s.add(e);
+            if (!s.contains(e))
+                fail ("Element not present after addition.");
+            if (added == prePresent)
+                fail ("added == alreadyPresent");
+            int postSize = s.size();
+            if (added && preSize == postSize)
+                fail ("Add returned true, but size didn't change.");
+            if (!added && preSize != postSize)
+                fail ("Add returned false, but size changed.");
+        }
+    }
+
+    static void fail(String s) {
+        throw new RuntimeException(s);
+
+    }
+}
diff --git a/test/java/util/Collections/Disjoint.java b/test/java/util/Collections/Disjoint.java
new file mode 100644
index 0000000..8d820f1
--- /dev/null
+++ b/test/java/util/Collections/Disjoint.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4339792
+ * @summary Basic test for Collections.disjoint
+ * @author  Josh Bloch
+ *
+ * @compile -source 1.5 Disjoint.java
+ * @run main Disjoint
+ */
+
+import java.util.*;
+
+public class Disjoint {
+    final static int N = 20;
+
+    public static void main(String args[]) {
+        // Make an array of lists each of which shares a single element
+        // with its "neighbors," and no elements with other lists in the array
+        Random rnd = new Random();
+        List[] lists = new List[N];
+        int x = 0;
+        for (int i = 0; i < N; i++) {
+            int size = rnd.nextInt(10) + 2;
+            List<Integer> list = new ArrayList<Integer>(size);
+            for (int j = 1; j < size; j++)
+                list.add(x++);
+            list.add(x);
+            Collections.shuffle(list);
+
+            lists[i] = list;
+        }
+
+        for (int i = 0; i < N; i++) {
+            for (int j = 0; j < N; j++) {
+                boolean disjoint = (Math.abs(i - j) > 1);
+                List<Integer> a = (List<Integer>) lists[i];
+                List<Integer> b = (List<Integer>) lists[j];
+
+                if (Collections.disjoint(a, b) != disjoint)
+                    throw new RuntimeException("A: " + i + ", " + j);
+                if (Collections.disjoint(new HashSet<Integer>(a), b)
+                    != disjoint)
+                    throw new RuntimeException("B: " + i + ", " + j);
+                if (Collections.disjoint(new HashSet<Integer>(a),
+                                         new HashSet<Integer>(b)) != disjoint)
+                    throw new RuntimeException("C: " + i + ", " + j);
+            }
+        }
+    }
+}
diff --git a/test/java/util/Collections/EmptyCollectionSerialization.java b/test/java/util/Collections/EmptyCollectionSerialization.java
new file mode 100644
index 0000000..e42a354
--- /dev/null
+++ b/test/java/util/Collections/EmptyCollectionSerialization.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4684279
+ * @summary Empty utility collections should be singletons
+ * @author  Josh Bloch
+ */
+
+import java.util.*;
+import java.io.*;
+
+public class EmptyCollectionSerialization {
+    private static Object patheticDeepCopy(Object o) throws Exception {
+        // Serialize
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(bos);
+        oos.writeObject(o);
+        byte[] serializedForm = bos.toByteArray();
+
+        // Deserialize
+        InputStream is = new ByteArrayInputStream(serializedForm);
+        ObjectInputStream ois = new ObjectInputStream(is);
+        return ois.readObject();
+    }
+
+    private static boolean isSingleton(Object o) throws Exception {
+        return patheticDeepCopy(o) == o;
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (!isSingleton(Collections.EMPTY_SET))
+            throw new Exception("EMPTY_SET");
+        if (!isSingleton(Collections.EMPTY_LIST))
+            throw new Exception("EMPTY_LIST");
+        if (!isSingleton(Collections.EMPTY_MAP))
+            throw new Exception("EMPTY_MAP");
+    }
+}
diff --git a/test/java/util/Collections/EmptyIterator.java b/test/java/util/Collections/EmptyIterator.java
new file mode 100644
index 0000000..69e5570
--- /dev/null
+++ b/test/java/util/Collections/EmptyIterator.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5017904 6356890
+ * @summary Test empty iterators, enumerations, and collections
+ */
+
+import java.util.*;
+import static java.util.Collections.*;
+
+public class EmptyIterator {
+
+    void test(String[] args) throws Throwable {
+        testEmptyCollection(Collections.<Object>emptyList());
+        testEmptyCollection(Collections.<Object>emptySet());
+        testEmptyCollection(new java.util.concurrent.
+                            SynchronousQueue<Object>());
+
+        testEmptyMap(Collections.<Object, Object>emptyMap());
+
+        Hashtable<Object, Object> emptyTable = new Hashtable<Object, Object>();
+        testEmptyEnumeration(emptyTable.keys());
+        testEmptyEnumeration(emptyTable.elements());
+        testEmptyIterator(emptyTable.keySet().iterator());
+        testEmptyIterator(emptyTable.values().iterator());
+        testEmptyIterator(emptyTable.entrySet().iterator());
+
+        testEmptyEnumeration(javax.swing.tree.DefaultMutableTreeNode
+                             .EMPTY_ENUMERATION);
+        testEmptyEnumeration(javax.swing.text.SimpleAttributeSet
+                             .EMPTY.getAttributeNames());
+
+        @SuppressWarnings("unchecked") Iterator<?> x =
+            new sun.tools.java.MethodSet()
+            .lookupName(sun.tools.java.Identifier.lookup(""));
+        testEmptyIterator(x);
+    }
+
+    <T> void testEmptyEnumeration(final Enumeration<T> e) {
+        check(e == emptyEnumeration());
+        check(! e.hasMoreElements());
+        THROWS(NoSuchElementException.class,
+               new F(){void f(){ e.nextElement(); }});
+    }
+
+    <T> void testEmptyIterator(final Iterator<T> it) {
+        check(it == emptyIterator());
+        check(! it.hasNext());
+        THROWS(NoSuchElementException.class,
+               new F(){void f(){ it.next(); }});
+        THROWS(IllegalStateException.class,
+               new F(){void f(){ it.remove(); }});
+    }
+
+    void testEmptyMap(Map<Object, Object> m) {
+        check(m == emptyMap());
+        check(m.entrySet().iterator() ==
+              Collections.<Map.Entry<Object,Object>>emptyIterator());
+        check(m.values().iterator() == emptyIterator());
+        check(m.keySet().iterator() == emptyIterator());
+        equal(m, unmodifiableMap(m));
+
+        testEmptyCollection(m.keySet());
+        testEmptyCollection(m.entrySet());
+        testEmptyCollection(m.values());
+    }
+
+    <E> void testToArray(final Collection<E> c) {
+        Object[] a = c.toArray();
+        equal(a.length, 0);
+        equal(a.getClass().getComponentType(), Object.class);
+        THROWS(NullPointerException.class,
+               new F(){void f(){ c.toArray((Object[])null); }});
+
+        {
+            String[] t = new String[0];
+            check(c.toArray(t) == t);
+        }
+
+        {
+            String[] t = nCopies(10, "").toArray(new String[0]);
+            check(c.toArray(t) == t);
+            check(t[0] == null);
+            for (int i=1; i<t.length; i++)
+                check(t[i] == "");
+        }
+    }
+
+    <E> void testEmptyCollection(final Collection<E> c) {
+        testEmptyIterator(c.iterator());
+
+        check(c.iterator() == emptyIterator());
+        if (c instanceof List)
+            check(((List<?>)c).listIterator() == emptyListIterator());
+
+        testToArray(c);
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    volatile int passed = 0, failed = 0;
+    void pass() {passed++;}
+    void fail() {failed++; Thread.dumpStack();}
+    void fail(String msg) {System.err.println(msg); fail();}
+    void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    void check(boolean cond) {if (cond) pass(); else fail();}
+    void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        new EmptyIterator().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");}
+    abstract class F {abstract void f() throws Throwable;}
+    void THROWS(Class<? extends Throwable> k, F... fs) {
+        for (F f : fs)
+            try {f.f(); fail("Expected " + k.getName() + " not thrown");}
+            catch (Throwable t) {
+                if (k.isAssignableFrom(t.getClass())) pass();
+                else unexpected(t);}}
+}
diff --git a/test/java/util/Collections/Enum.java b/test/java/util/Collections/Enum.java
new file mode 100644
index 0000000..66cd7bd
--- /dev/null
+++ b/test/java/util/Collections/Enum.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2000 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4323074
+ * @summary Basic test for new Enumeration -> List converter
+ */
+
+import java.util.*;
+
+public class Enum {
+    public static void main(String[] args) throws Exception {
+        int[] sizes = {0, 10, 100};
+        for (int i=0; i<sizes.length; i++) {
+            Vector v = new Vector();
+            int size = sizes[i];
+            for (int j=0; j<size; j++)
+                v.add(new Integer(j));
+            List l = Collections.list(v.elements());
+            if (!l.equals(v))
+                throw new Exception("Copy failed: "+size);
+        }
+    }
+}
diff --git a/test/java/util/Collections/FindSubList.java b/test/java/util/Collections/FindSubList.java
new file mode 100644
index 0000000..23d0ebf
--- /dev/null
+++ b/test/java/util/Collections/FindSubList.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2000 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4323074
+ * @summary Basic test for Collections.indexOfSubList/lastIndexOfSubList
+ */
+
+import java.util.*;
+
+public class FindSubList {
+    public static void main(String[] args) throws Exception {
+        int N = 500;
+        List source = new ArrayList(3 * N);
+        List target[]= new List[N+1];
+        int  index[] = new  int[N+1];
+        for (int i=0; i<=N; i++) {
+            List t = new ArrayList();
+            String s = Integer.toString(i, 2);
+            for (int j=0, len = s.length(); j<len; j++)
+                t.add(s.charAt(j)=='1' ? "1" : "0");
+            target[i] = t;
+            if (i == N) {
+                index[i] = -1;
+            } else {
+                index[i] = source.size();
+                source.addAll(t);
+                source.add("*");
+            }
+        }
+
+        List src[] = {source, new LinkedList(source), new Vector(source),
+                      Arrays.asList(source.toArray())};
+        for (int j=0; j<src.length; j++) {
+            List s = src[j];
+
+            for (int i=0; i<=N; i++) {
+                int idx = Collections.indexOfSubList(s, target[i]);
+                if (idx != index[i])
+                    throw new Exception(s.getClass()+" indexOfSubList: " + i +
+                                        "is " + idx + ", should be "+index[i]);
+            }
+
+            if (Collections.indexOfSubList(s,Collections.nCopies(2*s.size(),
+                                                                 "0")) != -1)
+               throw new Exception(s.getClass()+" indexOfSubList: big target");
+
+        }
+
+        Collections.reverse(source);
+        int srcSize = source.size();
+        for (int i=0; i<=N; i++) {
+            Collections.reverse(target[i]);
+            if (i != N)
+                index[i] = srcSize - index[i] - target[i].size();
+        }
+        List src2[] = {source, new LinkedList(source), new Vector(source),
+                       Arrays.asList(source.toArray())};
+        for (int j=0; j<src2.length; j++) {
+            List s = src2[j];
+
+            for (int i=0; i<=N; i++) {
+                int idx = Collections.lastIndexOfSubList(s, target[i]);
+                if (idx != index[i])
+                    throw new Exception(s.getClass()+" lastIdexOfSubList: "+i +
+                                        "is " + idx + ", should be "+index[i]);
+            }
+            if (Collections.indexOfSubList(s,Collections.nCopies(2*s.size(),
+                                                                 "0")) != -1)
+              throw new Exception(s.getClass()+" lastIndexOfSubList: big tgt");
+        }
+    }
+}
diff --git a/test/java/util/Collections/Frequency.java b/test/java/util/Collections/Frequency.java
new file mode 100644
index 0000000..a212657
--- /dev/null
+++ b/test/java/util/Collections/Frequency.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4193200
+ * @summary Basic test for Collections.frequency
+ * @author  Josh Bloch
+ *
+ * @compile -source 1.5 Frequency.java
+ * @run main Frequency
+ */
+
+import java.util.*;
+
+public class Frequency {
+    final static int N = 100;
+    public static void main(String args[]) {
+        test(new ArrayList<Integer>());
+        test(new LinkedList<Integer>());
+    }
+
+    static void test(List<Integer> list) {
+        for (int i = 0; i < N; i++)
+            for (int j = 0; j < i; j++)
+                list.add(i);
+        Collections.shuffle(list);
+
+        for (int i = 0; i < N; i++)
+            if (Collections.frequency(list, i) != i)
+                throw new RuntimeException(list.getClass() + ": " + i);
+    }
+}
diff --git a/test/java/util/Collections/MinMax.java b/test/java/util/Collections/MinMax.java
new file mode 100644
index 0000000..8ccc39c
--- /dev/null
+++ b/test/java/util/Collections/MinMax.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2001 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4486049
+ * @summary min and max methods fail if size changes in between a call to size
+ *           and an attempt to iterate.
+ * @author Josh Bloch
+ */
+
+import java.util.*;
+
+public class MinMax {
+    public static void main(String[] args) {
+        Set s = new LyingSet();
+        s.add("x");
+        if (!Collections.min(s).equals("x"))
+            throw new RuntimeException("1: " + Collections.min(s));
+        if (!Collections.max(s).equals("x"))
+            throw new RuntimeException("2: " + Collections.max(s));
+
+        s.add("y");
+        if (!Collections.min(s).equals("x"))
+            throw new RuntimeException("3: " + Collections.min(s));
+        if (!Collections.max(s).equals("y"))
+            throw new RuntimeException("4: " + Collections.max(s));
+
+        s.add("w");
+        if (!Collections.min(s).equals("w"))
+            throw new RuntimeException("5: " + Collections.min(s));
+        if (!Collections.max(s).equals("y"))
+            throw new RuntimeException("6: " + Collections.max(s));
+
+        s.clear();
+        s.add("x");
+        if (!Collections.min(s, Collections.reverseOrder()).equals("x"))
+            throw new RuntimeException("1a: " + Collections.min(s));
+        if (!Collections.max(s, Collections.reverseOrder()).equals("x"))
+            throw new RuntimeException("2a: " + Collections.max(s));
+
+        s.add("y");
+        if (!Collections.min(s, Collections.reverseOrder()).equals("y"))
+            throw new RuntimeException("3a: " + Collections.min(s));
+        if (!Collections.max(s, Collections.reverseOrder()).equals("x"))
+            throw new RuntimeException("4a: " + Collections.max(s));
+
+        s.add("w");
+        if (!Collections.min(s, Collections.reverseOrder()).equals("y"))
+            throw new RuntimeException("5a: " + Collections.min(s));
+        if (!Collections.max(s, Collections.reverseOrder()).equals("w"))
+            throw new RuntimeException("6a: " + Collections.max(s));
+    }
+}
+
+class LyingSet extends LinkedHashSet {
+    public int size() {
+        return super.size() + 1; // Lies, lies, all lies!
+    }
+}
diff --git a/test/java/util/Collections/NCopies.java b/test/java/util/Collections/NCopies.java
new file mode 100644
index 0000000..b37d8de
--- /dev/null
+++ b/test/java/util/Collections/NCopies.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6267846 6275009
+ * @summary Test Collections.nCopies
+ * @author  Martin Buchholz
+ */
+
+import java.util.*;
+import java.util.concurrent.*;
+
+public class NCopies {
+    static volatile int passed = 0, failed = 0;
+
+    static void fail(String msg) {
+        failed++;
+        new AssertionError(msg).printStackTrace();
+    }
+
+    static void pass() {
+        passed++;
+    }
+
+    static void unexpected(Throwable t) {
+        failed++;
+        t.printStackTrace();
+    }
+
+    static void check(boolean condition, String msg) {
+        if (condition)
+            passed++;
+        else
+            fail(msg);
+    }
+
+    static void check(boolean condition) {
+        check(condition, "Assertion failure");
+    }
+
+    private static void checkEmpty(List<String> x) {
+            check(x.isEmpty());
+            check(x.size() == 0);
+            check(x.indexOf("foo") == -1);
+            check(x.lastIndexOf("foo") == -1);
+            check(x.toArray().length == 0);
+            check(x.toArray().getClass() == Object[].class);
+    }
+
+    private static void checkFoos(List<String> x) {
+            check(! x.isEmpty());
+            check(x.indexOf(new String("foo")) == 0);
+            check(x.lastIndexOf(new String("foo")) == x.size()-1);
+            check(x.toArray().length == x.size());
+            check(x.toArray().getClass() == Object[].class);
+            String[] sa = x.toArray(new String[x.size()]);
+            check(sa.getClass() == String[].class);
+            check(sa[0].equals("foo"));
+            check(sa[sa.length-1].equals("foo"));
+            check(x.get(x.size()/2).equals("foo"));
+            checkEmpty(x.subList(x.size()/2, x.size()/2));
+    }
+
+    public static void main(String[] args) {
+        try {
+            List<String> empty = Collections.nCopies(0, "foo");
+            checkEmpty(empty);
+            checkEmpty(empty.subList(0,0));
+
+            List<String> foos = Collections.nCopies(42, "foo");
+            check(foos.size() == 42);
+            checkFoos(foos.subList(foos.size()/2, foos.size()-1));
+
+        } catch (Throwable t) { unexpected(t); }
+
+        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+        if (failed > 0) throw new Error("Some tests failed");
+    }
+}
diff --git a/test/java/util/Collections/NullComparator.java b/test/java/util/Collections/NullComparator.java
new file mode 100644
index 0000000..4320c5e
--- /dev/null
+++ b/test/java/util/Collections/NullComparator.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4224271
+ * @summary A null Comparator is now specified to indicate natural ordering.
+ */
+
+import java.util.*;
+
+public class NullComparator {
+    public static void main(String[] args) throws Exception {
+        List list = new ArrayList(100);
+        for (int i=0; i<100; i++)
+            list.add(new Integer(i));
+        List sorted = new ArrayList(list);
+        Collections.shuffle(list);
+
+        Object a[] = list.toArray();
+        Arrays.sort(a, null);
+        if (!Arrays.asList(a).equals(sorted))
+            throw new Exception("Arrays.sort");
+        a = list.toArray();
+        Arrays.sort(a, 0, 100, null);
+        if (!Arrays.asList(a).equals(sorted))
+            throw new Exception("Arrays.sort(from, to)");
+        if (Arrays.binarySearch(a, new Integer(69)) != 69)
+            throw new Exception("Arrays.binarySearch");
+
+        List tmp = new ArrayList(list);
+        Collections.sort(tmp, null);
+        if (!tmp.equals(sorted))
+            throw new Exception("Collections.sort");
+        if (Collections.binarySearch(tmp, new Integer(69)) != 69)
+            throw new Exception("Collections.binarySearch");
+        if (!Collections.min(list, null).equals(new Integer(0)))
+            throw new Exception("Collections.min");
+        if (!Collections.max(list, null).equals(new Integer(99)))
+            throw new Exception("Collections.max");
+    }
+}
diff --git a/test/java/util/Collections/RacingCollections.java b/test/java/util/Collections/RacingCollections.java
new file mode 100644
index 0000000..22f8867
--- /dev/null
+++ b/test/java/util/Collections/RacingCollections.java
@@ -0,0 +1,344 @@
+/*
+ * Copyright 2006-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6360946 6360948
+ * @summary Test various operations on concurrently mutating collections
+ * @author Martin Buchholz
+ */
+
+import static java.util.Collections.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+public class RacingCollections {
+    /**
+     * How long to run each "race" (in milliseconds).
+     * Turn this up to some higher value like 1000 for stress testing:
+     * java -Dmillis=1000 RacingCollections
+     */
+    final static long defaultWorkTimeMillis = Long.getLong("millis", 10L);
+
+    /**
+     * Whether to print debug information.
+     */
+    final static boolean debug = Boolean.getBoolean("debug");
+
+    final static Integer one = 1;
+    final static Integer two = 2;
+
+    /**
+     * A thread that mutates an object forever, alternating between
+     * being empty and containing singleton "two"
+     */
+    static class Frobber extends CheckedThread {
+        volatile boolean done = false;
+        boolean keepGoing(int i) { return (i % 128 != 0) || ! done; }
+
+        final Object elLoco;
+        Frobber(Object elLoco) {
+            this.elLoco = elLoco;
+            this.start();
+        }
+
+        @SuppressWarnings("unchecked") void clear(Object o) {
+            if (o instanceof Collection)
+                ((Collection<?>)o).clear();
+            else
+                ((Map<?,?>)o).clear();
+        }
+
+        @SuppressWarnings("unchecked") void realRun() {
+            // Mutate elLoco wildly forever, checking occasionally for "done"
+            clear(elLoco);
+            if (elLoco instanceof List) {
+                List<Integer> l = (List<Integer>) elLoco;
+                for (int i = 0; keepGoing(i); i++) {
+                    switch (i%2) {
+                    case 0: l.add(two);    break;
+                    case 1: l.add(0, two); break;
+                    }
+                    switch (i%2) {
+                    case 0: l.remove(two); break;
+                    case 1: l.remove(0);   break;
+                    }}}
+            else if (elLoco instanceof Deque) {
+                Deque<Integer> q = (Deque<Integer>) elLoco;
+                for (int i = 0; keepGoing(i); i++) {
+                    switch (i%6) {
+                    case 0: q.add(two);        break;
+                    case 1: q.addFirst(two);   break;
+                    case 2: q.addLast(two);    break;
+                    case 3: q.offer(two);      break;
+                    case 4: q.offerFirst(two); break;
+                    case 5: q.offerLast(two);  break;
+                    }
+                    switch (i%6) {
+                    case 0: q.remove(two);     break;
+                    case 1: q.removeFirst();   break;
+                    case 2: q.removeLast();    break;
+                    case 3: q.poll();          break;
+                    case 4: q.pollFirst();     break;
+                    case 5: q.pollLast();      break;
+                    }}}
+            else if (elLoco instanceof Queue) {
+                Queue<Integer> q = (Queue<Integer>) elLoco;
+                for (int i = 0; keepGoing(i); i++) {
+                    switch (i%2) {
+                    case 0: q.add(two);    break;
+                    case 1: q.offer(two);  break;
+                    }
+                    switch (i%2) {
+                    case 0: q.remove(two); break;
+                    case 1: q.poll();      break;
+                    }}}
+            else if (elLoco instanceof Map) {
+                Map<Integer, Boolean> m = (Map<Integer, Boolean>) elLoco;
+                for (int i = 0; keepGoing(i); i++) {
+                    m.put(two, true);
+                    m.remove(two);
+                }}
+            else if (elLoco instanceof Collection) {
+                Collection<Integer> c = (Collection<Integer>) elLoco;
+                for (int i = 0; keepGoing(i); i++) {
+                    c.add(two);
+                    c.remove(two);
+                }}
+            else { throw new Error("Huh? " + elLoco); }
+        }
+
+        void enoughAlready() {
+            done = true;
+            try { join(); } catch (Throwable t) { unexpected(t); }
+        }
+    }
+
+    private static void checkEqualSanity(Object theRock, Object elLoco) {
+        //equal(theRock, theRock);
+        equal(elLoco, elLoco);
+
+        // It would be nice someday to have theRock and elLoco never "equal",
+        // although the meaning of "equal" for mutating collections
+        // is a bit fuzzy.  Uncomment when/if we fix:
+        // 6374942: Improve thread safety of collection .equals() methods
+        //notEqual(theRock, elLoco);
+        //notEqual(elLoco, theRock);
+
+        notEqual(theRock.toString(), elLoco.toString());
+    }
+
+    static class Looper {
+        final long quittingTime;
+        int i = 0;
+        Looper() { this(defaultWorkTimeMillis); }
+        Looper(long workTimeMillis) {
+            quittingTime = System.nanoTime() + workTimeMillis * 1024 * 1024;
+        }
+        boolean keepGoing() {
+            return (i++ % 128 != 0) || (System.nanoTime() < quittingTime);
+        }
+    }
+
+    private static void frob(Object theRock, Object elLoco) {
+        Frobber frobber = new Frobber(elLoco);
+        try {
+            if (theRock instanceof Collection) {
+                @SuppressWarnings("unchecked")
+                Collection<Integer> c = (Collection<Integer>) theRock;
+                if (! c.contains(one))
+                    c.add(one);
+            } else {
+                @SuppressWarnings("unchecked")
+                Map<Integer, Boolean> m = (Map<Integer, Boolean>) theRock;
+                if (! m.containsKey(one))
+                    m.put(one, true);
+            }
+            for (Looper looper = new Looper(); looper.keepGoing(); )
+                checkEqualSanity(theRock, elLoco);
+        }
+        catch (Throwable t) { unexpected(t); }
+        finally { frobber.enoughAlready(); }
+    }
+
+    private static List<Map<Integer, Boolean>> newConcurrentMaps() {
+        List<Map<Integer, Boolean>> list =
+            new ArrayList<Map<Integer, Boolean>>();
+        list.add(new ConcurrentHashMap<Integer, Boolean>());
+        list.add(new ConcurrentSkipListMap<Integer, Boolean>());
+        return list;
+    }
+
+    private static List<Map<Integer, Boolean>> maps() {
+        List<Map<Integer, Boolean>> list = newConcurrentMaps();
+        list.add(new Hashtable<Integer, Boolean>());
+        list.add(new HashMap<Integer, Boolean>());
+        list.add(new TreeMap<Integer, Boolean>());
+        Comparator<Integer> cmp = new Comparator<Integer>() {
+            public int compare(Integer x, Integer y) {
+                return x - y;
+            }};
+        list.add(new TreeMap<Integer, Boolean>(Collections.reverseOrder(cmp)));
+        return list;
+    }
+
+    private static List<Set<Integer>> newConcurrentSets() {
+        List<Set<Integer>> list = new ArrayList<Set<Integer>>();
+        list.add(new ConcurrentSkipListSet<Integer>());
+        list.add(new CopyOnWriteArraySet<Integer>());
+        return list;
+    }
+
+    private static List<Set<Integer>> newSets() {
+        List<Set<Integer>> list = newConcurrentSets();
+        list.add(new HashSet<Integer>());
+        list.add(new TreeSet<Integer>());
+        list.add(new TreeSet<Integer>(Collections.reverseOrder()));
+        return list;
+    }
+
+    private static List<List<Integer>> newConcurrentLists() {
+        List<List<Integer>> list = new ArrayList<List<Integer>>();
+        list.add(new CopyOnWriteArrayList<Integer>());
+        return list;
+    }
+
+    private static List<List<Integer>> newLists() {
+        List<List<Integer>> list = newConcurrentLists();
+        list.add(new Vector<Integer>());
+        list.add(new ArrayList<Integer>());
+        return list;
+    }
+
+    private static List<Queue<Integer>> newConcurrentQueues() {
+        List<Queue<Integer>> list =
+            new ArrayList<Queue<Integer>>(newConcurrentDeques());
+        list.add(new LinkedBlockingQueue<Integer>(10));
+        return list;
+    }
+
+    private static List<Queue<Integer>> newQueues() {
+        List<Queue<Integer>> list =
+            new ArrayList<Queue<Integer>>(newDeques());
+        list.add(new LinkedBlockingQueue<Integer>(10));
+        return list;
+    }
+
+    private static List<Deque<Integer>> newConcurrentDeques() {
+        List<Deque<Integer>> list = new ArrayList<Deque<Integer>>();
+        list.add(new LinkedBlockingDeque<Integer>(10));
+        return list;
+    }
+
+    private static List<Deque<Integer>> newDeques() {
+        List<Deque<Integer>> list = newConcurrentDeques();
+        list.add(new ArrayDeque<Integer>());
+        list.add(new LinkedList<Integer>());
+        return list;
+    }
+
+    private static void describe(Class<?> k, Object x, Object y) {
+        if (debug)
+            System.out.printf("%s: %s, %s%n", k.getSimpleName(),
+                              x.getClass().getSimpleName(),
+                              y.getClass().getSimpleName());
+    }
+
+    private static void realMain(String[] args) {
+        for (Map<Integer, Boolean> x : maps())
+            for (Map<Integer, Boolean> y : newConcurrentMaps()) {
+                describe(Map.class, x, y);
+                x.put(one, true);
+                frob(x, y);
+                frob(unmodifiableMap(x), y);
+                frob(synchronizedMap(x), y);
+                frob(x, synchronizedMap(y));
+                frob(checkedMap(x, Integer.class, Boolean.class), y);
+                frob(x, checkedMap(y, Integer.class, Boolean.class));
+                x.clear();
+                frob(newSetFromMap(x), newSetFromMap(y));
+                frob(x.keySet(), newSetFromMap(y));
+            }
+
+        for (Set<Integer> x : newSets())
+            for (Set<Integer> y : newConcurrentSets()) {
+                describe(Set.class, x, y);
+                frob(x, y);
+                frob(unmodifiableSet(x), y);
+                frob(synchronizedSet(x), y);
+                frob(x, synchronizedSet(y));
+                frob(checkedSet(x, Integer.class), y);
+                frob(x, checkedSet(y, Integer.class));
+            }
+
+        for (List<Integer> x : newLists())
+            for (List<Integer> y : newConcurrentLists()) {
+                describe(List.class, x, y);
+                frob(x, y);
+                frob(unmodifiableList(x), y);
+                frob(synchronizedList(x), y);
+                frob(x, synchronizedList(y));
+                frob(checkedList(x, Integer.class), y);
+                frob(x, checkedList(y, Integer.class));
+            }
+
+        for (Queue<Integer> x : newQueues())
+            for (Queue<Integer> y : newConcurrentQueues()) {
+                describe(Queue.class, x, y);
+                frob(x, y);
+            }
+
+        for (Deque<Integer> x : newDeques())
+            for (Deque<Integer> y : newConcurrentDeques()) {
+                describe(Deque.class, x, y);
+                frob(asLifoQueue(x), y);
+                frob(x, asLifoQueue(y));
+            }
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    static volatile int passed = 0, failed = 0;
+    static void pass() {passed++;}
+    static void fail() {failed++; Thread.dumpStack();}
+    static void fail(String msg) {System.out.println(msg); fail();}
+    static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    static void check(boolean cond) {if (cond) pass(); else fail();}
+    static String toString(Object x) {
+        return ((x instanceof Collection) || (x instanceof Map)) ?
+            x.getClass().getName() : x.toString();}
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(toString(x) + " not equal to " + toString(y));}
+    static void notEqual(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y))
+            fail(toString(x) + " equal to " + toString(y));
+        else pass();}
+    public static void main(String[] args) throws Throwable {
+        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 {
+        abstract void realRun() throws Throwable;
+        public void run() {
+            try { realRun(); } catch (Throwable t) { unexpected(t); }}}
+}
diff --git a/test/java/util/Collections/ReplaceAll.java b/test/java/util/Collections/ReplaceAll.java
new file mode 100644
index 0000000..e91a76e
--- /dev/null
+++ b/test/java/util/Collections/ReplaceAll.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2000 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4323074
+ * @summary Basic test for new replaceAll algorithm
+ */
+
+import java.util.*;
+
+public class ReplaceAll {
+    static final int SIZE = 20;
+
+    public static void main(String[] args) throws Exception {
+        List a[] = {new ArrayList(), new LinkedList(), new Vector()};
+
+        for (int i=0; i<a.length; i++) {
+            List lst = a[i];
+            for (int j=1; j<=SIZE; j++)
+                lst.add(new Integer(j % 3));
+            List goal = Collections.nCopies(SIZE, "*");
+
+            for (int j=0; j<3; j++) {
+                List before = new ArrayList(lst);
+                if (!Collections.replaceAll(lst, new Integer(j), "*"))
+                    throw new Exception("False return value: "+i+", "+j);
+                if (lst.equals(before))
+                    throw new Exception("Unchanged: "+i+", "+j+", "+": "+lst);
+                if (lst.equals(goal) != (j==2))
+                    throw new Exception("Wrong change:"+i+", "+j);
+            }
+            if (Collections.replaceAll(lst, "love", "hate"))
+                throw new Exception("True return value: "+i);
+        }
+    }
+}
diff --git a/test/java/util/Collections/ReverseOrder.java b/test/java/util/Collections/ReverseOrder.java
new file mode 100644
index 0000000..ea0b97b
--- /dev/null
+++ b/test/java/util/Collections/ReverseOrder.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4593209
+ * @summary Reverse comparator was subtly broken
+ * @author Josh bloch
+ */
+
+import java.util.*;
+
+public class ReverseOrder {
+    public static void main(String[] args) throws Exception {
+        Foo[] a = { new Foo(2), new Foo(3), new Foo(1) };
+        List list = Arrays.asList(a);
+        Collections.sort(list, Collections.reverseOrder());
+
+        Foo[] golden = { new Foo(3), new Foo(2), new Foo(1) };
+        List goldenList = Arrays.asList(golden);
+        if (!list.equals(goldenList))
+            throw new Exception(list.toString());
+    }
+}
+
+class Foo implements Comparable {
+    int val;
+    Foo(int i) { val = i; }
+
+    public int compareTo(Object o) {
+        Foo f = (Foo)o;
+        return (val < f.val ? Integer.MIN_VALUE : (val == f.val ? 0 : 1));
+    }
+
+    public boolean equals(Object o) {
+        return o instanceof Foo && ((Foo)o).val == val;
+    }
+
+    public int hashCode()    { return val; }
+
+    public String toString() { return Integer.toString(val); }
+}
diff --git a/test/java/util/Collections/ReverseOrder2.java b/test/java/util/Collections/ReverseOrder2.java
new file mode 100644
index 0000000..d0499ba
--- /dev/null
+++ b/test/java/util/Collections/ReverseOrder2.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     4809442 6366832 4974878 6372554 4890211 6483125
+ * @summary Basic test for Collections.reverseOrder
+ * @author  Josh Bloch, Martin Buchholz
+ */
+
+import java.util.*;
+import java.io.*;
+
+public class ReverseOrder2 {
+    final static int N = 100;
+
+    static void realMain(String[] args) throws Throwable {
+        check(Collections.reverseOrder()
+              == Collections.reverseOrder(null));
+
+        check(Collections.reverseOrder()
+              == reincarnate(Collections.reverseOrder()));
+
+        check(Collections.reverseOrder(Collections.reverseOrder(cmp))
+              == cmp);
+
+        equal(Collections.reverseOrder(cmp),
+              Collections.reverseOrder(cmp));
+
+        equal(Collections.reverseOrder(cmp).hashCode(),
+              Collections.reverseOrder(cmp).hashCode());
+
+        check(Collections.reverseOrder(cmp).hashCode() !=
+              cmp.hashCode());
+
+        test(new ArrayList<String>());
+        test(new LinkedList<String>());
+        test2(new ArrayList<Integer>());
+        test2(new LinkedList<Integer>());
+    }
+
+    static void test(List<String> list) {
+        for (int i = 0; i < N; i++)
+            list.add(String.valueOf(i));
+        Collections.shuffle(list);
+        Collections.sort(list, Collections.reverseOrder(cmp));
+        equal(list, golden);
+    }
+
+    private static Comparator<String> cmp = new Comparator<String> () {
+        public int compare(String s1, String s2) {
+            int i1 = Integer.parseInt(s1);
+            int i2 = Integer.parseInt(s2);
+            return (i1 < i2 ? Integer.MIN_VALUE : (i1 == i2 ? 0 : 1));
+        }
+    };
+
+    private final static List<String> golden = new ArrayList<String>(N);
+    static {
+        for (int i = N-1; i >= 0; i--)
+            golden.add(String.valueOf(i));
+    }
+
+    static void test2(List<Integer> list) {
+        for (int i = 0; i < N; i++)
+            list.add(i);
+        Collections.shuffle(list);
+        Collections.sort(list, Collections.reverseOrder(null));
+        equal(list, golden2);
+    }
+
+    private final static List<Integer> golden2 = new ArrayList<Integer>(N);
+    static {
+        for (int i = N-1; i >= 0; i--)
+            golden2.add(i);
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    static volatile int passed = 0, failed = 0;
+    static void pass() {passed++;}
+    static void fail() {failed++; Thread.dumpStack();}
+    static void fail(String msg) {System.out.println(msg); fail();}
+    static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    static void check(boolean cond) {if (cond) pass(); else fail();}
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        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 byte[] serializedForm(Object obj) {
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            new ObjectOutputStream(baos).writeObject(obj);
+            return baos.toByteArray();
+        } catch (IOException e) {throw new RuntimeException(e);}}
+    static Object readObject(byte[] bytes)
+        throws IOException, ClassNotFoundException {
+        InputStream is = new ByteArrayInputStream(bytes);
+        return new ObjectInputStream(is).readObject();}
+    @SuppressWarnings("unchecked")
+    static <T> T reincarnate(T obj) {
+        try {return (T) readObject(serializedForm(obj));}
+        catch (Exception e) {throw new RuntimeException(e);}}
+}
diff --git a/test/java/util/Collections/Rotate.java b/test/java/util/Collections/Rotate.java
new file mode 100644
index 0000000..df5a92c
--- /dev/null
+++ b/test/java/util/Collections/Rotate.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4323074
+ * @summary Basic test for new rotate algorithm
+ */
+
+import java.util.*;
+
+public class Rotate {
+    // Should have lots of distinct factors and be > ROTATE_THRESHOLD
+    static final int SIZE = 120;
+
+    static Random rnd = new Random();
+
+    public static void main(String[] args) throws Exception {
+        List a[] = {new ArrayList(), new LinkedList(), new Vector()};
+
+        for (int i=0; i<a.length; i++) {
+            List lst = a[i];
+            for (int j=0; j<SIZE; j++)
+                lst.add(new Integer(j));
+            int totalDist = 0;
+
+            for (int j=0; j<10000; j++) {
+                int dist = rnd.nextInt(200) - 100;
+                Collections.rotate(lst, dist);
+
+                // Check that things are as they should be
+                totalDist = (totalDist + dist) % SIZE;
+                if (totalDist < 0)
+                    totalDist += SIZE;
+                int index =0;
+                for (int k=totalDist; k<SIZE; k++, index++)
+                    if (((Integer)lst.get(k)).intValue() != index)
+                        throw new Exception("j: "+j+", lst["+k+"]="+lst.get(k)+
+                                            ", should be "+index);
+                for (int k=0; k<totalDist; k++, index++)
+                    if (((Integer)lst.get(k)).intValue() != index)
+                        throw new Exception("j: "+j+", lst["+k+"]="+lst.get(k)+
+                                            ", should be "+index);
+            }
+        }
+    }
+}
diff --git a/test/java/util/Collections/RotateEmpty.java b/test/java/util/Collections/RotateEmpty.java
new file mode 100644
index 0000000..67e8853
--- /dev/null
+++ b/test/java/util/Collections/RotateEmpty.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4389747
+ * @summary Collections.rotate(...) returns ArithmeticException
+ */
+
+import java.util.*;
+
+public class RotateEmpty {
+
+    public static void main(String[] args) throws Exception {
+            List l = new ArrayList();
+            Collections.rotate (l, 1);
+    }
+}
diff --git a/test/java/util/Collections/Ser.java b/test/java/util/Collections/Ser.java
new file mode 100644
index 0000000..19088a1
--- /dev/null
+++ b/test/java/util/Collections/Ser.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4190323
+ * @summary EMPTY_SET, EMPTY_LIST, and the collections returned by
+ *          nCopies and singleton were spec'd to be serializable, but weren't.
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class Ser {
+    public static void main(String[] args) throws Exception {
+
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            ObjectOutputStream out = new ObjectOutputStream(bos);
+            out.writeObject(Collections.EMPTY_SET);
+            out.flush();
+            ObjectInputStream in = new ObjectInputStream(
+                    new ByteArrayInputStream(bos.toByteArray()));
+
+            if (!Collections.EMPTY_SET.equals(in.readObject()))
+                throw new RuntimeException("empty set Ser/Deser failure.");
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to serialize empty set:" + e);
+        }
+
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            ObjectOutputStream out = new ObjectOutputStream(bos);
+            out.writeObject(Collections.EMPTY_LIST);
+            out.flush();
+            ObjectInputStream in = new ObjectInputStream(
+                    new ByteArrayInputStream(bos.toByteArray()));
+
+            if (!Collections.EMPTY_LIST.equals(in.readObject()))
+                throw new RuntimeException("empty list Ser/Deser failure.");
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to serialize empty list:" + e);
+        }
+
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            ObjectOutputStream out = new ObjectOutputStream(bos);
+            Set gumby = Collections.singleton("gumby");
+            out.writeObject(gumby);
+            out.flush();
+            ObjectInputStream in = new ObjectInputStream(
+                    new ByteArrayInputStream(bos.toByteArray()));
+
+            if (!gumby.equals(in.readObject()))
+                throw new RuntimeException("Singleton Ser/Deser failure.");
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to serialize singleton:" + e);
+        }
+
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            ObjectOutputStream out = new ObjectOutputStream(bos);
+            List gumbies = Collections.nCopies(50, "gumby");
+            out.writeObject(gumbies);
+            out.flush();
+            ObjectInputStream in = new ObjectInputStream(
+                    new ByteArrayInputStream(bos.toByteArray()));
+
+            if (!gumbies.equals(in.readObject()))
+                throw new RuntimeException("nCopies Ser/Deser failure.");
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to serialize nCopies:" + e);
+        }
+    }
+}
diff --git a/test/java/util/Collections/SetFromMap.java b/test/java/util/Collections/SetFromMap.java
new file mode 100644
index 0000000..b37cff8
--- /dev/null
+++ b/test/java/util/Collections/SetFromMap.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6301089
+ * @summary test Collections.newSetFromMap
+ * @author Martin Buchholz
+ */
+
+import java.util.*;
+
+public class SetFromMap {
+    static volatile int passed = 0, failed = 0;
+    static void pass() { passed++; }
+    static void fail() { failed++; Thread.dumpStack(); }
+    static void unexpected(Throwable t) { failed++; t.printStackTrace(); }
+    static void check(boolean cond) { if (cond) pass(); else fail(); }
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else {System.out.println(x + " not equal to " + y); fail(); }}
+
+    public static void main(String[] args) throws Throwable {
+        try { realMain(); } catch (Throwable t) { unexpected(t); }
+
+        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+        if (failed > 0) throw new Exception("Some tests failed");
+    }
+
+    private static void realMain() throws Throwable {
+        try {
+            Map<String,Boolean> m = new IdentityHashMap<String,Boolean>();
+            Set<String> s = Collections.newSetFromMap(m);
+            String foo1 = new String("foo");
+            String foo2 = new String("foo");
+            String bar = new String("bar");
+            check(s.add(foo1));
+            check(s.add(foo2));
+            check(s.add(bar));
+            equal(s.size(), 3);
+            check(s.contains(foo1));
+            check(s.contains(foo2));
+            check(! s.contains(new String(foo1)));
+        } catch (Throwable t) { unexpected(t); }
+    }
+}
diff --git a/test/java/util/Collections/Swap.java b/test/java/util/Collections/Swap.java
new file mode 100644
index 0000000..5e4bc2d
--- /dev/null
+++ b/test/java/util/Collections/Swap.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug     4323074
+ * @summary Basic test for newly public swap algorithm
+ * @author  Josh Bloch
+ */
+
+import java.util.*;
+
+public class Swap {
+    static final int SIZE = 100;
+
+    public static void main(String[] args) throws Exception {
+        List l = new ArrayList(Collections.nCopies(100, Boolean.FALSE));
+        l.set(0, Boolean.TRUE);
+        for (int i=0; i < SIZE-1; i++)
+            Collections.swap(l, i, i+1);
+
+        List l2 = new ArrayList(Collections.nCopies(100, Boolean.FALSE));
+        l2.set(SIZE-1, Boolean.TRUE);
+        if (!l.equals(l2))
+            throw new RuntimeException("Wrong result");
+    }
+}
diff --git a/test/java/util/Collections/T5078378.java b/test/java/util/Collections/T5078378.java
new file mode 100644
index 0000000..e96732c
--- /dev/null
+++ b/test/java/util/Collections/T5078378.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 5078378
+ * @summary REGRESSION: Some calls to Collections.binarySearch no longer compile
+ * @author Peter von der Ah\u00e9
+ *
+ * @compile T5078378.java
+ * @compile/fail -Xlint:unchecked -Werror T5078378.java
+ */
+import java.util.*;
+
+class T5078378 {
+    public static boolean contains(List l, Object o) {
+        return Collections.binarySearch(l, o) > -1;
+    }
+}
diff --git a/test/java/util/Collections/T6433170.java b/test/java/util/Collections/T6433170.java
new file mode 100644
index 0000000..3cf0078
--- /dev/null
+++ b/test/java/util/Collections/T6433170.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6433170
+ * @summary CheckedCollection.addAll should be all-or-nothing
+ */
+
+import java.util.*;
+import static java.util.Collections.*;
+
+@SuppressWarnings("unchecked")
+public class T6433170 {
+    private void checkEmpty(Collection x) {
+        check(x.isEmpty());
+        check(x.size() == 0);
+        check(x.toArray().length == 0);
+    }
+
+    void test(String[] args) throws Throwable {
+        test(checkedList(
+                 checkedList(new ArrayList(), String.class),
+                 Object.class));
+        test(checkedSet(
+                 checkedSet(new HashSet(), String.class),
+                 Object.class));
+        test(checkedCollection(
+                 checkedCollection(new Vector(), String.class),
+                 Object.class));
+    }
+
+    void test(final Collection checked) {
+        checkEmpty(checked);
+        final List mixedList = Arrays.asList("1", 2, "3");
+        THROWS(ClassCastException.class,
+               new F(){void f(){ checked.addAll(mixedList); }});
+        checkEmpty(checked);
+    }
+
+
+    //--------------------- Infrastructure ---------------------------
+    volatile int passed = 0, failed = 0;
+    void pass() {passed++;}
+    void fail() {failed++; Thread.dumpStack();}
+    void fail(String msg) {System.err.println(msg); fail();}
+    void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    void check(boolean cond) {if (cond) pass(); else fail();}
+    void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        new T6433170().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");}
+    abstract class F {abstract void f() throws Throwable;}
+    void THROWS(Class<? extends Throwable> k, F... fs) {
+        for (F f : fs)
+            try {f.f(); fail("Expected " + k.getName() + " not thrown");}
+            catch (Throwable t) {
+                if (k.isAssignableFrom(t.getClass())) pass();
+                else unexpected(t);}}
+}
diff --git a/test/java/util/Collections/ViewSynch.java b/test/java/util/Collections/ViewSynch.java
new file mode 100644
index 0000000..e975250
--- /dev/null
+++ b/test/java/util/Collections/ViewSynch.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 4268780
+ * @summary Collection-views of submap-views of synchronized-views of
+ *          SortedMap objects do not synchronize on the correct object.
+ *          (Got that?)
+ */
+
+import java.util.*;
+
+public class ViewSynch {
+    static final Integer ZERO = new Integer(0);
+    static final Int INT_ZERO = new Int(0);
+    static final Int INT_ONE = new Int(1);
+    static SortedMap m = Collections.synchronizedSortedMap(new TreeMap());
+    static Map m2 = m.tailMap(ZERO);
+    static Collection c = m2.values();
+
+    public static void main(String[] args) {
+        for (int i=0; i<10000; i++)
+            m.put(new Integer(i), INT_ZERO);
+
+        new Thread() {
+            public void run() {
+                for (int i=0; i<100; i++) {
+                    Thread.yield();
+                    m.remove(ZERO);
+                    m.put(ZERO, INT_ZERO);
+                }
+            }
+        }.start();
+
+        c.contains(INT_ONE);
+    }
+}
+
+/**
+ * Like Integer, except yields while doing equals comparison, to allow
+ * for interleaving.
+ */
+class Int {
+    Integer x;
+    Int(int i) {x = new Integer(i);}
+
+    public boolean equals(Object o) {
+        Thread.yield();
+        Int i = (Int)o;
+        return x.equals(i.x);
+    }
+
+    public int hashCode() {return x.hashCode();}
+}
diff --git a/test/java/util/Collections/WrappedNull.java b/test/java/util/Collections/WrappedNull.java
new file mode 100644
index 0000000..4a965db
--- /dev/null
+++ b/test/java/util/Collections/WrappedNull.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4189641
+ * @summary Wrapping a null collection/array should blow up sooner
+ *          rather than later
+ */
+
+import java.util.*;
+
+public class WrappedNull {
+      public static void main(String argv[]) throws Exception {
+          boolean testSucceeded = false;
+          try{
+              List l = Arrays.asList(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("Arrays.asList");
+
+          testSucceeded = false;
+          try{
+              Collection c = Collections.unmodifiableCollection(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("unmodifiableCollection");
+
+          testSucceeded = false;
+          try{
+              Set c = Collections.unmodifiableSet(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("unmodifiableSet");
+
+          testSucceeded = false;
+          try{
+              List c = Collections.unmodifiableList(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("unmodifiableList");
+
+          testSucceeded = false;
+          try{
+              Map c = Collections.unmodifiableMap(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("unmodifiableMap");
+
+          testSucceeded = false;
+          try{
+              SortedSet c = Collections.unmodifiableSortedSet(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("unmodifiableSortedSet");
+
+          testSucceeded = false;
+          try{
+              SortedMap c = Collections.unmodifiableSortedMap(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("unmodifiableSortedMap");
+
+          testSucceeded = false;
+          try{
+              Collection c = Collections.synchronizedCollection(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("synchronizedCollection");
+
+          testSucceeded = false;
+          try{
+              Set c = Collections.synchronizedSet(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("synchronizedSet");
+
+          testSucceeded = false;
+          try{
+              List c = Collections.synchronizedList(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("synchronizedList");
+
+          testSucceeded = false;
+          try{
+              Map c = Collections.synchronizedMap(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("synchronizedMap");
+
+          testSucceeded = false;
+          try{
+              SortedSet c = Collections.synchronizedSortedSet(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("synchronizedSortedSet");
+
+          testSucceeded = false;
+          try{
+              SortedMap c = Collections.synchronizedSortedMap(null);
+          }
+          catch (NullPointerException e) {
+              testSucceeded = true;
+          }
+          if(!testSucceeded)
+              throw new Exception("synchronizedSortedMap");
+
+          // Make sure that non-null arguments don't throw exc.
+          List l = Arrays.asList(new Object[0]);
+          Collection c = Collections.unmodifiableCollection(
+                             Collections.EMPTY_SET);
+          Set s = Collections.unmodifiableSet(Collections.EMPTY_SET);
+          l = Collections.unmodifiableList(Collections.EMPTY_LIST);
+          Map m = Collections.unmodifiableMap(Collections.EMPTY_MAP);
+          SortedSet ss = Collections.unmodifiableSortedSet(new TreeSet());
+          SortedMap sm = Collections.unmodifiableSortedMap(new TreeMap());
+
+          c = Collections.synchronizedCollection(Collections.EMPTY_SET);
+          s = Collections.synchronizedSet(Collections.EMPTY_SET);
+          l = Collections.synchronizedList(Collections.EMPTY_LIST);
+          m = Collections.synchronizedMap(Collections.EMPTY_MAP);
+          ss = Collections.synchronizedSortedSet(new TreeSet());
+          sm = Collections.synchronizedSortedMap(new TreeMap());
+      }
+}