changeset 8259:96be5e1ae7d5

address review comments for 8001647
author akhil
date Fri, 19 Apr 2013 14:45:28 -0700
parents 960b36d46727
children 641cdd0f39c8
files src/share/classes/java/util/ArrayList.java src/share/classes/java/util/Collection.java src/share/classes/java/util/List.java src/share/classes/java/util/Vector.java test/java/util/Collection/CollectionDefaults.java test/java/util/Collection/ListDefaults.java test/java/util/Collection/testlibrary/CollectionAsserts.java test/java/util/Collection/testlibrary/CollectionSupplier.java test/java/util/CollectionExtensionMethods/CollectionExtensionMethodsTest.java test/java/util/CollectionExtensionMethods/ListExtensionMethodsTest.java test/java/util/CollectionExtensionMethods/Wrappers.java test/java/util/CollectionExtensionMethods/testlibrary/CollectionAsserts.java test/java/util/CollectionExtensionMethods/testlibrary/CollectionSupplier.java test/java/util/Collections/Wrappers.java
diffstat 14 files changed, 1296 insertions(+), 1302 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/ArrayList.java	Fri Apr 19 16:26:16 2013 -0400
+++ b/src/share/classes/java/util/ArrayList.java	Fri Apr 19 14:45:28 2013 -0700
@@ -1253,7 +1253,6 @@
                 removeCount++;
             }
         }
-
         if (modCount != expectedModCount) {
             throw new ConcurrentModificationException();
         }
@@ -1262,12 +1261,11 @@
         final boolean anyToRemove = removeCount > 0;
         if (anyToRemove) {
             final int newSize = size - removeCount;
-            for (int i=0, j=0; modCount == expectedModCount &&
-                    (i < size) && (j < newSize); i++, j++) {
+            for (int i=0, j=0; (i < size) && (j < newSize); i++, j++) {
                 i = removeSet.nextClearBit(i);
                 elementData[j] = elementData[i];
             }
-            for (int k=newSize; modCount == expectedModCount && k < size; k++) {
+            for (int k=newSize; k < size; k++) {
                 elementData[k] = null;  // Let gc do its work
             }
             this.size = newSize;
--- a/src/share/classes/java/util/Collection.java	Fri Apr 19 16:26:16 2013 -0400
+++ b/src/share/classes/java/util/Collection.java	Fri Apr 19 14:45:28 2013 -0700
@@ -377,8 +377,9 @@
     boolean removeAll(Collection<?> c);
 
     /**
-     * Removes all of the elements of this collection which match the provided
-     * predicate.  Exceptions thrown by the predicate are relayed to the caller.
+     * Removes all of the elements of this collection that satisfy the given
+     * predicate.  RuntimeExceptions and Errors thrown by the predicate are
+     * propagated to the caller.
      *
      * @implSpec
      * The default implementation traverses all elements of the collection using
--- a/src/share/classes/java/util/List.java	Fri Apr 19 16:26:16 2013 -0400
+++ b/src/share/classes/java/util/List.java	Fri Apr 19 14:45:28 2013 -0700
@@ -396,9 +396,9 @@
      * @param operator the operator to apply to each element
      * @throws UnsupportedOperationException if the <code>replaceAll</code>
      *         operation is not supported by this list
-     * @throws NullPointerException if the specified operator is null
-     * @throws NullPointerException if the an element is replaced with a null
-     *         value and this list does not permit null elements
+     * @throws NullPointerException if the specified operator is null or
+     *         if the element is replaced with a null value and this list
+     *         does not permit null elements
      * (<a href="Collection.html#optional-restrictions">optional</a>)
      * @since 1.8
      */
@@ -420,13 +420,14 @@
      * @param c the {@code Comparator} used to compare list elements.
      *          A {@code null} value indicates that the elements'
      *          {@linkplain Comparable natural ordering} should be used.
-     * @since 1.8
      * @throws ClassCastException if the list contains elements that are not
      *         <i>mutually comparable</i> using the specified comparator.
      * @throws UnsupportedOperationException if the list's list-iterator does
      *         not support the {@code set} operation.
-     * @throws IllegalArgumentException (optional) if the comparator is
-     *         found to violate the {@link Comparator} contract
+     * @throws IllegalArgumentException
+     *         (<a href="#optional-restrictions">optional</a>) if the
+     *         comparator is found to violate the {@link Comparator} contract
+     * @since 1.8
      */
     default void sort(Comparator<? super E> c) {
         Collections.sort(this, c);
--- a/src/share/classes/java/util/Vector.java	Fri Apr 19 16:26:16 2013 -0400
+++ b/src/share/classes/java/util/Vector.java	Fri Apr 19 14:45:28 2013 -0700
@@ -1270,7 +1270,6 @@
                 removeCount++;
             }
         }
-
         if (modCount != expectedModCount) {
             throw new ConcurrentModificationException();
         }
@@ -1279,12 +1278,11 @@
         final boolean anyToRemove = removeCount > 0;
         if (anyToRemove) {
             final int newSize = size - removeCount;
-            for (int i=0, j=0; modCount == expectedModCount &&
-                    (i < size) && (j < newSize); i++, j++) {
+            for (int i=0, j=0; (i < size) && (j < newSize); i++, j++) {
                 i = removeSet.nextClearBit(i);
                 elementData[j] = elementData[i];
             }
-            for (int k=newSize; modCount == expectedModCount && k < size; k++) {
+            for (int k=newSize; k < size; k++) {
                 elementData[k] = null;  // Let gc do its work
             }
             elementCount = newSize;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Collection/CollectionDefaults.java	Fri Apr 19 14:45:28 2013 -0700
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.function.Predicate;
+
+/**
+ * @test
+ * @library testlibrary
+ * @build CollectionAsserts CollectionSupplier
+ * @run testng CollectionDefaults
+ * @summary Unit tests for extension methods on Collection
+ */
+public class CollectionDefaults {
+
+    public static final Predicate<Integer> pEven = x -> 0 == x % 2;
+    public static final Predicate<Integer> pOdd = x -> 1 == x % 2;
+
+    private static final String[] SET_CLASSES = {
+        "java.util.HashSet",
+        "java.util.LinkedHashSet",
+        "java.util.TreeSet"
+    };
+
+    private static final int SIZE = 100;
+
+    @DataProvider(name="setProvider", parallel=true)
+    public static Object[][] setCases() {
+        final List<Object[]> cases = new LinkedList<>();
+        cases.add(new Object[] { new HashSet<>() });
+        cases.add(new Object[] { new LinkedHashSet<>() });
+        cases.add(new Object[] { new TreeSet<>() });
+
+        cases.add(new Object[] { Collections.newSetFromMap(new HashMap<>()) });
+        cases.add(new Object[] { Collections.newSetFromMap(new LinkedHashMap()) });
+        cases.add(new Object[] { Collections.newSetFromMap(new TreeMap<>()) });
+
+        cases.add(new Object[] { new HashSet(){{add(42);}} });
+        cases.add(new Object[] { new LinkedHashSet(){{add(42);}} });
+        cases.add(new Object[] { new TreeSet(){{add(42);}} });
+        return cases.toArray(new Object[0][cases.size()]);
+    }
+
+    @Test(dataProvider = "setProvider")
+    public void testProvidedWithNull(final Set<Integer> set) throws Exception {
+        try {
+            set.forEach(null);
+            fail("expected NPE not thrown");
+        } catch (NullPointerException npe) {}
+        try {
+            set.removeIf(null);
+            fail("expected NPE not thrown");
+        } catch (NullPointerException npe) {}
+    }
+
+    @Test
+    public void testForEach() throws Exception {
+        final CollectionSupplier supplier = new CollectionSupplier(SET_CLASSES, SIZE);
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final Set<Integer> original = ((Set<Integer>) test.original);
+            final Set<Integer> set = ((Set<Integer>) test.collection);
+
+            try {
+                set.forEach(null);
+                fail("expected NPE not thrown");
+            } catch (NullPointerException npe) {}
+            if (test.className.equals("java.util.HashSet")) {
+                CollectionAsserts.assertContentsUnordered(set, original);
+            } else {
+                CollectionAsserts.assertContents(set, original);
+            }
+
+            final List<Integer> actual = new LinkedList<>();
+            set.forEach(actual::add);
+            if (test.className.equals("java.util.HashSet")) {
+                CollectionAsserts.assertContentsUnordered(actual, set);
+                CollectionAsserts.assertContentsUnordered(actual, original);
+            } else {
+                CollectionAsserts.assertContents(actual, set);
+                CollectionAsserts.assertContents(actual, original);
+            }
+        }
+    }
+
+    @Test
+    public void testRemoveIf() throws Exception {
+        final CollectionSupplier supplier = new CollectionSupplier(SET_CLASSES, SIZE);
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final Set<Integer> original = ((Set<Integer>) test.original);
+            final Set<Integer> set = ((Set<Integer>) test.collection);
+
+            try {
+                set.removeIf(null);
+                fail("expected NPE not thrown");
+            } catch (NullPointerException npe) {}
+            if (test.className.equals("java.util.HashSet")) {
+                CollectionAsserts.assertContentsUnordered(set, original);
+            } else {
+                CollectionAsserts.assertContents(set, original);
+            }
+
+            set.removeIf(pEven);
+            for (int i : set) {
+                assertTrue((i % 2) == 1);
+            }
+            for (int i : original) {
+                if (i % 2 == 1) {
+                    assertTrue(set.contains(i));
+                }
+            }
+            set.removeIf(pOdd);
+            assertTrue(set.isEmpty());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Collection/ListDefaults.java	Fri Apr 19 14:45:28 2013 -0700
@@ -0,0 +1,484 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Comparators;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Stack;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Vector;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.lang.reflect.Constructor;
+import java.util.ConcurrentModificationException;
+import java.util.function.Predicate;
+
+/**
+ * @test
+ * @library testlibrary
+ * @build CollectionAsserts CollectionSupplier
+ * @run testng ListDefaults
+ * @summary Unit tests for extension methods on List
+ */
+public class ListDefaults {
+
+    private static final String[] LIST_CLASSES = {
+        "java.util.ArrayList",
+        "java.util.LinkedList",
+        "java.util.Vector",
+        "java.util.concurrent.CopyOnWriteArrayList"
+    };
+
+    private static final String[] LIST_CME_CLASSES = {
+        "java.util.ArrayList",
+        "java.util.Vector"
+    };
+
+    private static final Predicate<Integer> pEven = x -> 0 == x % 2;
+    private static final Predicate<Integer> pOdd = x -> 1 == x % 2;
+
+    private static final Comparator<Integer> BIT_COUNT_COMPARATOR =
+            (x, y) -> Integer.bitCount(x) - Integer.bitCount(y);
+
+    private static final Comparator<AtomicInteger> ATOMIC_INTEGER_COMPARATOR =
+            (x, y) -> x.intValue() - y.intValue();
+
+    private static final int SIZE = 100;
+    private static final int SUBLIST_FROM = 2;
+    private static final int SUBLIST_TO = SIZE - SUBLIST_FROM;
+    private static final int SUBLIST_SIZE = SUBLIST_TO - SUBLIST_FROM;
+
+    private static interface Callback {
+        void call(List<Integer> list);
+    }
+
+    // call the callback for each recursive subList
+    private void trimmedSubList(final List<Integer> list, final Callback callback) {
+        int size = list.size();
+        if (size > 1) {
+            // trim 1 element from both ends
+            final List<Integer> subList = list.subList(1, size - 1);
+            callback.call(subList);
+            trimmedSubList(subList, callback);
+        }
+    }
+
+    @DataProvider(name="listProvider", parallel=true)
+    public static Object[][] listCases() {
+        final List<Object[]> cases = new LinkedList<>();
+        cases.add(new Object[] { new ArrayList<>() });
+        cases.add(new Object[] { new LinkedList<>() });
+        cases.add(new Object[] { new Vector<>() });
+        cases.add(new Object[] { new Stack<>() });
+        cases.add(new Object[] { new CopyOnWriteArrayList<>() });
+
+        cases.add(new Object[] { new ArrayList(){{add(42);}} });
+        cases.add(new Object[] { new LinkedList(){{add(42);}} });
+        cases.add(new Object[] { new Vector(){{add(42);}} });
+        cases.add(new Object[] { new Stack(){{add(42);}} });
+        cases.add(new Object[] { new CopyOnWriteArrayList(){{add(42);}} });
+        return cases.toArray(new Object[0][cases.size()]);
+    }
+
+    @Test(dataProvider = "listProvider")
+    public void testProvidedWithNull(final List<Integer> list) throws Exception {
+        try {
+            list.forEach(null);
+            fail("expected NPE not thrown");
+        } catch (NullPointerException npe) {}
+        try {
+            list.replaceAll(null);
+            fail("expected NPE not thrown");
+        } catch (NullPointerException npe) {}
+        try {
+            list.removeIf(null);
+            fail("expected NPE not thrown");
+        } catch (NullPointerException npe) {}
+    }
+
+    @Test
+    public void testForEach() throws Exception {
+        final CollectionSupplier supplier = new CollectionSupplier(LIST_CLASSES, SIZE);
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> original = ((List<Integer>) test.original);
+            final List<Integer> list = ((List<Integer>) test.collection);
+        }
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> original = ((List<Integer>) test.original);
+            final List<Integer> list = ((List<Integer>) test.collection);
+
+            try {
+                list.forEach(null);
+                fail("expected NPE not thrown");
+            } catch (NullPointerException npe) {}
+            CollectionAsserts.assertContents(list, original);
+
+            final List<Integer> actual = new LinkedList<>();
+            list.forEach(actual::add);
+            CollectionAsserts.assertContents(actual, list);
+            CollectionAsserts.assertContents(actual, original);
+
+            if (original.size() > SUBLIST_SIZE) {
+                final List<Integer> subList = original.subList(SUBLIST_FROM, SUBLIST_TO);
+                final List<Integer> actualSubList = new LinkedList<>();
+                subList.forEach(actualSubList::add);
+                assertEquals(actualSubList.size(), SUBLIST_SIZE);
+                for (int i = 0; i < SUBLIST_SIZE; i++) {
+                    assertEquals(actualSubList.get(i), original.get(i + SUBLIST_FROM));
+                }
+            }
+
+            trimmedSubList(list, new Callback() {
+                @Override
+                public void call(final List<Integer> list) {
+                    final List<Integer> actual = new LinkedList<>();
+                    list.forEach(actual::add);
+                    CollectionAsserts.assertContents(actual, list);
+                }
+            });
+        }
+    }
+
+    @Test
+    public void testRemoveIf() throws Exception {
+        final CollectionSupplier supplier = new CollectionSupplier(LIST_CLASSES, SIZE);
+
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> original = ((List<Integer>) test.original);
+            final List<Integer> list = ((List<Integer>) test.collection);
+
+            try {
+                list.removeIf(null);
+                fail("expected NPE not thrown");
+            } catch (NullPointerException npe) {}
+            CollectionAsserts.assertContents(list, original);
+
+            final AtomicInteger offset = new AtomicInteger(1);
+            while (list.size() > 0) {
+                removeFirst(original, list, offset);
+            }
+        }
+
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> original = ((List<Integer>) test.original);
+            final List<Integer> list = ((List<Integer>) test.collection);
+            list.removeIf(pOdd);
+            for (int i : list) {
+                assertTrue((i % 2) == 0);
+            }
+            for (int i : original) {
+                if (i % 2 == 0) {
+                    assertTrue(list.contains(i));
+                }
+            }
+            list.removeIf(pEven);
+            assertTrue(list.isEmpty());
+        }
+
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> original = ((List<Integer>) test.original);
+            final List<Integer> list = ((List<Integer>) test.collection);
+            final List<Integer> listCopy = new ArrayList<>(list);
+            if (original.size() > SUBLIST_SIZE) {
+                final List<Integer> subList = list.subList(SUBLIST_FROM, SUBLIST_TO);
+                final List<Integer> subListCopy = new ArrayList<>(subList);
+                listCopy.removeAll(subList);
+                subList.removeIf(pOdd);
+                for (int i : subList) {
+                    assertTrue((i % 2) == 0);
+                }
+                for (int i : subListCopy) {
+                    if (i % 2 == 0) {
+                        assertTrue(subList.contains(i));
+                    } else {
+                        assertFalse(subList.contains(i));
+                    }
+                }
+                subList.removeIf(pEven);
+                assertTrue(subList.isEmpty());
+                // elements outside the view should remain
+                CollectionAsserts.assertContents(list, listCopy);
+            }
+        }
+
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> list = ((List<Integer>) test.collection);
+            trimmedSubList(list, new Callback() {
+                @Override
+                public void call(final List<Integer> list) {
+                    final List<Integer> copy = new ArrayList<>(list);
+                    list.removeIf(pOdd);
+                    for (int i : list) {
+                        assertTrue((i % 2) == 0);
+                    }
+                    for (int i : copy) {
+                        if (i % 2 == 0) {
+                            assertTrue(list.contains(i));
+                        } else {
+                            assertFalse(list.contains(i));
+                        }
+                    }
+                }
+            });
+        }
+    }
+
+    // remove the first element
+    private void removeFirst(final List<Integer> original, final List<Integer> list, final AtomicInteger offset) {
+        final AtomicBoolean first = new AtomicBoolean(true);
+        list.removeIf(x -> first.getAndSet(false));
+        CollectionAsserts.assertContents(original.subList(offset.getAndIncrement(), original.size()), list);
+    }
+
+    @Test
+    public void testReplaceAll() throws Exception {
+        final int scale = 3;
+        final CollectionSupplier supplier = new CollectionSupplier(LIST_CLASSES, SIZE);
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> original = ((List<Integer>) test.original);
+            final List<Integer> list = ((List<Integer>) test.collection);
+
+            try {
+                list.replaceAll(null);
+                fail("expected NPE not thrown");
+            } catch (NullPointerException npe) {}
+            CollectionAsserts.assertContents(list, original);
+
+            list.replaceAll(x -> scale * x);
+            for (int i=0; i < original.size(); i++) {
+                assertTrue(list.get(i) == (scale * original.get(i)), "mismatch at index " + i);
+            }
+
+            if (original.size() > SUBLIST_SIZE) {
+                final List<Integer> subList = list.subList(SUBLIST_FROM, SUBLIST_TO);
+                subList.replaceAll(x -> x + 1);
+                // verify elements in view [from, to) were replaced
+                for (int i = 0; i < SUBLIST_SIZE; i++) {
+                    assertTrue(subList.get(i) == ((scale * original.get(i + SUBLIST_FROM)) + 1),
+                            "mismatch at sublist index " + i);
+                }
+                // verify that elements [0, from) remain unmodified
+                for (int i = 0; i < SUBLIST_FROM; i++) {
+                    assertTrue(list.get(i) == (scale * original.get(i)),
+                            "mismatch at original index " + i);
+                }
+                // verify that elements [to, size) remain unmodified
+                for (int i = SUBLIST_TO; i < list.size(); i++) {
+                    assertTrue(list.get(i) == (scale * original.get(i)),
+                            "mismatch at original index " + i);
+                }
+            }
+        }
+
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> list = ((List<Integer>) test.collection);
+            trimmedSubList(list, new Callback() {
+                @Override
+                public void call(final List<Integer> list) {
+                    final List<Integer> copy = new ArrayList<>(list);
+                    final int offset = 5;
+                    list.replaceAll(x -> offset + x);
+                    for (int i=0; i < copy.size(); i++) {
+                        assertTrue(list.get(i) == (offset + copy.get(i)), "mismatch at index " + i);
+                    }
+                }
+            });
+        }
+    }
+
+    @Test
+    public void testSort() throws Exception {
+        final CollectionSupplier supplier = new CollectionSupplier(LIST_CLASSES, SIZE);
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> original = ((List<Integer>) test.original);
+            final List<Integer> list = ((List<Integer>) test.collection);
+            CollectionSupplier.shuffle(list);
+            list.sort(Integer::compare);
+            CollectionAsserts.assertSorted(list, Integer::compare);
+            if (test.name.startsWith("reverse")) {
+                Collections.reverse(list);
+            }
+            CollectionAsserts.assertContents(list, original);
+
+            CollectionSupplier.shuffle(list);
+            list.sort(null);
+            CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder());
+            if (test.name.startsWith("reverse")) {
+                Collections.reverse(list);
+            }
+            CollectionAsserts.assertContents(list, original);
+
+            CollectionSupplier.shuffle(list);
+            list.sort(Comparators.<Integer>naturalOrder());
+            CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder());
+            if (test.name.startsWith("reverse")) {
+                Collections.reverse(list);
+            }
+            CollectionAsserts.assertContents(list, original);
+
+            CollectionSupplier.shuffle(list);
+            list.sort(Comparators.<Integer>reverseOrder());
+            CollectionAsserts.assertSorted(list, Comparators.<Integer>reverseOrder());
+            if (!test.name.startsWith("reverse")) {
+                Collections.reverse(list);
+            }
+            CollectionAsserts.assertContents(list, original);
+
+            CollectionSupplier.shuffle(list);
+            list.sort(BIT_COUNT_COMPARATOR);
+            CollectionAsserts.assertSorted(list, BIT_COUNT_COMPARATOR);
+            // check sort by verifying that bitCount increases and never drops
+            int minBitCount = 0;
+            int bitCount = 0;
+            for (final Integer i : list) {
+                bitCount = Integer.bitCount(i);
+                assertTrue(bitCount >= minBitCount);
+                minBitCount = bitCount;
+            }
+
+            @SuppressWarnings("unchecked")
+            final Class<? extends List<AtomicInteger>> type =
+                    (Class<? extends List<AtomicInteger>>) Class.forName(test.className);
+            final Constructor<? extends List<AtomicInteger>> defaultConstructor = type.getConstructor();
+            final List<AtomicInteger> incomparables = (List<AtomicInteger>) defaultConstructor.newInstance();
+
+            for (int i=0; i < test.original.size(); i++) {
+                incomparables.add(new AtomicInteger(i));
+            }
+            CollectionSupplier.shuffle(incomparables);
+            incomparables.sort(ATOMIC_INTEGER_COMPARATOR);
+            for (int i=0; i < test.original.size(); i++) {
+                assertEquals(i, incomparables.get(i).intValue());
+            }
+
+            if (original.size() > SUBLIST_SIZE) {
+                final List<Integer> copy = new ArrayList<>(list);
+                final List<Integer> subList = list.subList(SUBLIST_FROM, SUBLIST_TO);
+                CollectionSupplier.shuffle(subList);
+                subList.sort(Comparators.<Integer>naturalOrder());
+                CollectionAsserts.assertSorted(subList, Comparators.<Integer>naturalOrder());
+                // verify that elements [0, from) remain unmodified
+                for (int i = 0; i < SUBLIST_FROM; i++) {
+                    assertTrue(list.get(i) == copy.get(i),
+                            "mismatch at index " + i);
+                }
+                // verify that elements [to, size) remain unmodified
+                for (int i = SUBLIST_TO; i < list.size(); i++) {
+                    assertTrue(list.get(i) == copy.get(i),
+                            "mismatch at index " + i);
+                }
+            }
+        }
+
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> list = ((List<Integer>) test.collection);
+            trimmedSubList(list, new Callback() {
+                @Override
+                public void call(final List<Integer> list) {
+                    final List<Integer> copy = new ArrayList<>(list);
+                    CollectionSupplier.shuffle(list);
+                    list.sort(Comparators.<Integer>naturalOrder());
+                    CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder());
+                }
+            });
+        }
+    }
+
+    @Test
+    public void testRemoveIfThrowsCME() throws Exception {
+        final CollectionSupplier supplier = new CollectionSupplier(LIST_CME_CLASSES, SIZE);
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> list = ((List<Integer>) test.collection);
+            if (list.size() <= 1) {
+                continue;
+            }
+            boolean gotException = false;
+            try {
+                // bad predicate that modifies its list, should throw CME
+                list.removeIf((x) -> {return list.add(x);});
+            } catch (ConcurrentModificationException cme) {
+                gotException = true;
+            }
+            if (!gotException) {
+                fail("expected CME was not thrown from " + test);
+            }
+        }
+    }
+
+    @Test
+    public void testReplaceAllThrowsCME() throws Exception {
+        final CollectionSupplier supplier = new CollectionSupplier(LIST_CME_CLASSES, SIZE);
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> list = ((List<Integer>) test.collection);
+            if (list.size() <= 1) {
+                continue;
+            }
+            boolean gotException = false;
+            try {
+                // bad predicate that modifies its list, should throw CME
+                list.replaceAll(x -> {int n = 3 * x; list.add(n); return n;});
+            } catch (ConcurrentModificationException cme) {
+                gotException = true;
+            }
+            if (!gotException) {
+                fail("expected CME was not thrown from " + test);
+            }
+        }
+    }
+
+    @Test
+    public void testSortThrowsCME() throws Exception {
+        final CollectionSupplier supplier = new CollectionSupplier(LIST_CME_CLASSES, SIZE);
+        for (final CollectionSupplier.TestCase test : supplier.get()) {
+            final List<Integer> list = ((List<Integer>) test.collection);
+            if (list.size() <= 1) {
+                continue;
+            }
+            boolean gotException = false;
+            try {
+                // bad predicate that modifies its list, should throw CME
+                list.sort((x, y) -> {list.add(x); return x - y;});
+            } catch (ConcurrentModificationException cme) {
+                gotException = true;
+            }
+            if (!gotException) {
+                fail("expected CME was not thrown from " + test);
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Collection/testlibrary/CollectionAsserts.java	Fri Apr 19 14:45:28 2013 -0700
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+/**
+ * @library
+ * CollectionAssert -- assertion methods for lambda test cases
+ */
+public class CollectionAsserts {
+
+    public static void assertCountSum(Iterable<? super Integer> it, int count, int sum) {
+        assertCountSum(it.iterator(), count, sum);
+    }
+
+    public static void assertCountSum(Iterator<? super Integer> it, int count, int sum) {
+        int c = 0;
+        int s = 0;
+        while (it.hasNext()) {
+            int i = (Integer) it.next();
+            c++;
+            s += i;
+        }
+
+        assertEquals(c, count);
+        assertEquals(s, sum);
+    }
+
+    public static void assertConcat(Iterator<Character> it, String result) {
+        StringBuilder sb = new StringBuilder();
+        while (it.hasNext()) {
+            sb.append(it.next());
+        }
+
+        assertEquals(result, sb.toString());
+    }
+
+    public static<T extends Comparable<? super T>> void assertSorted(Iterator<T> i) {
+        if (!i.hasNext())
+            return;
+        T last = i.next();
+        while (i.hasNext()) {
+            T t = i.next();
+            assertTrue(last.compareTo(t) <= 0);
+            assertTrue(t.compareTo(last) >= 0);
+            last = t;
+        }
+    }
+
+    public static<T> void assertSorted(Iterator<T> i, Comparator<? super T> comp) {
+        if (!i.hasNext())
+            return;
+        T last = i.next();
+        while (i.hasNext()) {
+            T t = i.next();
+            assertTrue(comp.compare(last, t) <= 0);
+            assertTrue(comp.compare(t, last) >= 0);
+            last = t;
+        }
+    }
+
+    public static<T extends Comparable<? super T>> void assertSorted(Iterable<T> iter) {
+        assertSorted(iter.iterator());
+    }
+
+    public static<T> void assertSorted(Iterable<T> iter, Comparator<? super T> comp) {
+        assertSorted(iter.iterator(), comp);
+    }
+
+    public static <T> void assertUnique(Iterable<T> iter) {
+        assertUnique(iter.iterator());
+    }
+
+    public static<T> void assertUnique(Iterator<T> iter) {
+        if (!iter.hasNext()) {
+            return;
+        }
+
+        Set<T> uniq = new HashSet<>();
+        while(iter.hasNext()) {
+            T each = iter.next();
+            assertTrue(!uniq.contains(each));
+            uniq.add(each);
+        }
+    }
+
+    public static<T> void assertContents(Iterable<T> actual, Iterable<T> expected) {
+        assertContents(actual.iterator(), expected.iterator());
+    }
+
+    public static<T> void assertContents(Iterator<T> actual, Iterator<T> expected) {
+        List<T> history = new ArrayList<>();
+
+        while (expected.hasNext()) {
+            if (!actual.hasNext()) {
+                List<T> expectedData = new ArrayList<>(history);
+                while (expected.hasNext())
+                    expectedData.add(expected.next());
+                fail(String.format("Premature end of data; expected=%s, found=%s", expectedData, history));
+            }
+            T a = actual.next();
+            T e = expected.next();
+            history.add(a);
+
+            if (!Objects.equals(a, e))
+                fail(String.format("Data mismatch; preceding=%s, nextExpected=%s, nextFound=%s", history, e, a));
+        }
+        if (actual.hasNext()) {
+            List<T> rest = new ArrayList<>();
+            while (actual.hasNext())
+                rest.add(actual.next());
+            fail(String.format("Unexpected data %s after %s", rest, history));
+        }
+    }
+
+    @SafeVarargs
+    @SuppressWarnings("varargs")
+    public static<T> void assertContents(Iterator<T> actual, T... expected) {
+        assertContents(actual, Arrays.asList(expected).iterator());
+    }
+
+    public static <T> boolean equalsContentsUnordered(Iterable<T> a, Iterable<T> b) {
+        Set<T> sa = new HashSet<>();
+        for (T t : a) {
+            sa.add(t);
+        }
+
+        Set<T> sb = new HashSet<>();
+        for (T t : b) {
+            sb.add(t);
+        }
+
+        return Objects.equals(sa, sb);
+    }
+
+    public static<T extends Comparable<? super T>> void assertContentsUnordered(Iterable<T> actual, Iterable<T> expected) {
+        ArrayList<T> one = new ArrayList<>();
+        for (T t : actual)
+            one.add(t);
+        ArrayList<T> two = new ArrayList<>();
+        for (T t : expected)
+            two.add(t);
+        Collections.sort(one);
+        Collections.sort(two);
+        assertContents(one, two);
+    }
+
+    static <T> void assertSplitContents(Iterable<Iterable<T>> splits, Iterable<T> list) {
+        Iterator<Iterable<T>> mI = splits.iterator();
+        Iterator<T> pI = null;
+        Iterator<T> lI = list.iterator();
+
+        while (lI.hasNext()) {
+            if (pI == null)
+                pI = mI.next().iterator();
+            while (!pI.hasNext()) {
+                if (!mI.hasNext()) {
+                    break;
+                }
+                else {
+                    pI = mI.next().iterator();
+                }
+            }
+            assertTrue(pI.hasNext());
+            T pT = pI.next();
+            T lT = lI.next();
+            assertEquals(pT, lT);
+        }
+
+        if (pI != null) {
+            assertTrue(!pI.hasNext());
+        }
+
+        while(mI.hasNext()) {
+            pI = mI.next().iterator();
+            assertTrue(!pI.hasNext());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Collection/testlibrary/CollectionSupplier.java	Fri Apr 19 14:45:28 2013 -0700
@@ -0,0 +1,304 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.Exception;
+import java.lang.Integer;
+import java.lang.Iterable;
+import java.lang.Override;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+
+import org.testng.TestException;
+
+import static org.testng.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.function.Supplier;
+
+/**
+ * @library
+ * @summary A Supplier of test cases for Collection tests
+ */
+public final class CollectionSupplier implements Supplier<Iterable<CollectionSupplier.TestCase>> {
+
+    private final String[] classNames;
+    private final int size;
+
+    /**
+     * A Collection test case.
+     */
+    public static final class TestCase {
+
+        /**
+         * The name of the test case.
+         */
+        public final String name;
+
+        /**
+         * Class name of the instantiated Collection.
+         */
+        public final String className;
+
+        /**
+         * Unmodifiable reference collection, useful for comparisons.
+         */
+        public final Collection<Integer> original;
+
+        /**
+         * A modifiable test collection.
+         */
+        public final Collection<Integer> collection;
+
+        /**
+         * Create a Collection test case.
+         * @param name name of the test case
+         * @param className class name of the instantiated collection
+         * @param original reference collection
+         * @param collection the modifiable test collection
+         */
+        public TestCase(String name, String className,
+                Collection<Integer> original, Collection<Integer> collection) {
+            this.name = name;
+            this.className = className;
+            this.original =
+                    List.class.isAssignableFrom(original.getClass()) ?
+                    Collections.unmodifiableList((List<Integer>) original) :
+                    Set.class.isAssignableFrom(original.getClass()) ?
+                    Collections.unmodifiableSet((Set<Integer>) original) :
+                    Collections.unmodifiableCollection(original);
+            this.collection = collection;
+        }
+
+        @Override
+        public String toString() {
+            return name + " " + className +
+                    "\n original: " + original +
+                    "\n   target: " + collection;
+        }
+    }
+
+    /**
+     * Shuffle a list using a PRNG with known seed for repeatability
+     * @param list the list to be shuffled
+     */
+    public static <E> void shuffle(final List<E> list) {
+        // PRNG with known seed for repeatable tests
+        final Random prng = new Random(13);
+        final int size = list.size();
+        for (int i=0; i < size; i++) {
+            // random index in interval [i, size)
+            final int j = i + prng.nextInt(size - i);
+            // swap elements at indices i & j
+            final E e = list.get(i);
+            list.set(i, list.get(j));
+            list.set(j, e);
+        }
+    }
+
+    /**
+     * Create a {@code Supplier} that creates instances of specified collection
+     * classes of specified length.
+     *
+     * @param classNames class names that implement {@code Collection}
+     * @param size the desired size of each collection
+     */
+    public CollectionSupplier(String[] classNames, int size) {
+        this.classNames = Arrays.copyOf(classNames, classNames.length);
+        this.size = size;
+    }
+
+    @Override
+    public Iterable<TestCase> get() {
+        try {
+            return getThrows();
+        } catch (Exception e) {
+            throw new TestException(e);
+        }
+    }
+
+    private Iterable<TestCase> getThrows() throws Exception {
+        final Collection<TestCase> collections = new LinkedList<>();
+        for (final String className : classNames) {
+            @SuppressWarnings("unchecked")
+            final Class<? extends Collection<Integer>> type =
+                    (Class<? extends Collection<Integer>>) Class.forName(className);
+            final Constructor<? extends Collection<Integer>>
+                    defaultConstructor = type.getConstructor();
+            final Constructor<? extends Collection<Integer>>
+                    copyConstructor = type.getConstructor(Collection.class);
+
+            final Collection<Integer> empty = defaultConstructor.newInstance();
+            collections.add(new TestCase("empty",
+                    className,
+                    copyConstructor.newInstance(empty),
+                    empty));
+
+            final Collection<Integer> single = defaultConstructor.newInstance();
+            single.add(42);
+            collections.add(new TestCase("single",
+                    className,
+                    copyConstructor.newInstance(single),
+                    single));
+
+            final Collection<Integer> regular = defaultConstructor.newInstance();
+            for (int i=0; i < size; i++) {
+                regular.add(i);
+            }
+            collections.add(new TestCase("regular",
+                    className,
+                    copyConstructor.newInstance(regular),
+                    regular));
+
+            final Collection<Integer> reverse = defaultConstructor.newInstance();
+            for (int i=size; i >= 0; i--) {
+                reverse.add(i);
+            }
+            collections.add(new TestCase("reverse",
+                    className,
+                    copyConstructor.newInstance(reverse),
+                    reverse));
+
+            final Collection<Integer> odds = defaultConstructor.newInstance();
+            for (int i=0; i < size; i++) {
+                odds.add((i * 2) + 1);
+            }
+            collections.add(new TestCase("odds",
+                    className,
+                    copyConstructor.newInstance(odds),
+                    odds));
+
+            final Collection<Integer> evens = defaultConstructor.newInstance();
+            for (int i=0; i < size; i++) {
+                evens.add(i * 2);
+            }
+            collections.add(new TestCase("evens",
+                    className,
+                    copyConstructor.newInstance(evens),
+                    evens));
+
+            final Collection<Integer> fibonacci = defaultConstructor.newInstance();
+            int prev2 = 0;
+            int prev1 = 1;
+            for (int i=0; i < size; i++) {
+                final int n = prev1 + prev2;
+                if (n < 0) { // stop on overflow
+                    break;
+                }
+                fibonacci.add(n);
+                prev2 = prev1;
+                prev1 = n;
+            }
+            collections.add(new TestCase("fibonacci",
+                    className,
+                    copyConstructor.newInstance(fibonacci),
+                    fibonacci));
+
+            // variants where the size of the backing storage != reported size
+            // created by removing half of the elements
+
+            final Collection<Integer> emptyWithSlack = defaultConstructor.newInstance();
+            emptyWithSlack.add(42);
+            assertTrue(emptyWithSlack.remove(42));
+            collections.add(new TestCase("emptyWithSlack",
+                    className,
+                    copyConstructor.newInstance(emptyWithSlack),
+                    emptyWithSlack));
+
+            final Collection<Integer> singleWithSlack = defaultConstructor.newInstance();
+            singleWithSlack.add(42);
+            singleWithSlack.add(43);
+            assertTrue(singleWithSlack.remove(43));
+            collections.add(new TestCase("singleWithSlack",
+                    className,
+                    copyConstructor.newInstance(singleWithSlack),
+                    singleWithSlack));
+
+            final Collection<Integer> regularWithSlack = defaultConstructor.newInstance();
+            for (int i=0; i < (2 * size); i++) {
+                regularWithSlack.add(i);
+            }
+            assertTrue(regularWithSlack.removeIf((x) -> {return x >= size;}));
+            collections.add(new TestCase("regularWithSlack",
+                    className,
+                    copyConstructor.newInstance(regularWithSlack),
+                    regularWithSlack));
+
+            final Collection<Integer> reverseWithSlack = defaultConstructor.newInstance();
+            for (int i=2 * size; i >= 0; i--) {
+                reverseWithSlack.add(i);
+            }
+            assertTrue(reverseWithSlack.removeIf((x) -> {return x < size;}));
+            collections.add(new TestCase("reverseWithSlack",
+                    className,
+                    copyConstructor.newInstance(reverseWithSlack),
+                    reverseWithSlack));
+
+            final Collection<Integer> oddsWithSlack = defaultConstructor.newInstance();
+            for (int i = 0; i < 2 * size; i++) {
+                oddsWithSlack.add((i * 2) + 1);
+            }
+            assertTrue(oddsWithSlack.removeIf((x) -> {return x >= size;}));
+            collections.add(new TestCase("oddsWithSlack",
+                    className,
+                    copyConstructor.newInstance(oddsWithSlack),
+                    oddsWithSlack));
+
+            final Collection<Integer> evensWithSlack = defaultConstructor.newInstance();
+            for (int i = 0; i < 2 * size; i++) {
+                evensWithSlack.add(i * 2);
+            }
+            assertTrue(evensWithSlack.removeIf((x) -> {return x >= size;}));
+            collections.add(new TestCase("evensWithSlack",
+                    className,
+                    copyConstructor.newInstance(evensWithSlack),
+                    evensWithSlack));
+
+            final Collection<Integer> fibonacciWithSlack = defaultConstructor.newInstance();
+            prev2 = 0;
+            prev1 = 1;
+            for (int i=0; i < size; i++) {
+                final int n = prev1 + prev2;
+                if (n < 0) { // stop on overflow
+                    break;
+                }
+                fibonacciWithSlack.add(n);
+                prev2 = prev1;
+                prev1 = n;
+            }
+            assertTrue(fibonacciWithSlack.removeIf((x) -> {return x < 20;}));
+            collections.add(new TestCase("fibonacciWithSlack",
+                    className,
+                    copyConstructor.newInstance(fibonacciWithSlack),
+                    fibonacciWithSlack));
+
+        }
+
+        return collections;
+    }
+
+}
--- a/test/java/util/CollectionExtensionMethods/CollectionExtensionMethodsTest.java	Fri Apr 19 16:26:16 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2012 Oracle and/or its affiliates. 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.util.TreeSet;
-import java.util.function.Predicate;
-
-/**
- * @test
- * @library testlibrary
- * @build CollectionAsserts CollectionSupplier
- * @run testng CollectionExtensionMethodsTest
- * @summary Unit tests for extension methods on Collection
- */
-public class CollectionExtensionMethodsTest {
-
-    public static final Predicate<Integer> pEven = x -> 0 == x % 2;
-    public static final Predicate<Integer> pOdd = x -> 1 == x % 2;
-
-    private static final String[] SET_CLASSES = {
-        "java.util.HashSet",
-        "java.util.LinkedHashSet",
-        "java.util.TreeSet"
-    };
-
-    private static final int SIZE = 100;
-
-    @DataProvider(name="setProvider")
-    public static Object[][] setCases() {
-        final List<Object[]> cases = new LinkedList<>();
-        cases.add(new Object[] { new HashSet<>() });
-        cases.add(new Object[] { new LinkedHashSet<>() });
-        cases.add(new Object[] { new TreeSet<>() });
-
-        cases.add(new Object[] { new HashSet(){{add(42);}} });
-        cases.add(new Object[] { new LinkedHashSet(){{add(42);}} });
-        cases.add(new Object[] { new TreeSet(){{add(42);}} });
-        return cases.toArray(new Object[0][cases.size()]);
-    }
-
-    @Test(dataProvider = "setProvider")
-    public void testProvidedWithNull(final Set<Integer> set) throws Exception {
-        try {
-            set.forEach(null);
-            fail("expected NPE not thrown");
-        } catch (NullPointerException npe) {}
-        try {
-            set.removeIf(null);
-            fail("expected NPE not thrown");
-        } catch (NullPointerException npe) {}
-    }
-
-    @Test
-    public void testForEach() throws Exception {
-        final CollectionSupplier supplier = new CollectionSupplier(SET_CLASSES, SIZE);
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final Set<Integer> original = ((Set<Integer>) test.original);
-            final Set<Integer> set = ((Set<Integer>) test.collection);
-
-            try {
-                set.forEach(null);
-                fail("expected NPE not thrown");
-            } catch (NullPointerException npe) {}
-            if (test.className.equals("java.util.HashSet")) {
-                CollectionAsserts.assertContentsUnordered(set, original);
-            } else {
-                CollectionAsserts.assertContents(set, original);
-            }
-
-            final List<Integer> actual = new LinkedList<>();
-            set.forEach(actual::add);
-            if (test.className.equals("java.util.HashSet")) {
-                CollectionAsserts.assertContentsUnordered(actual, set);
-                CollectionAsserts.assertContentsUnordered(actual, original);
-            } else {
-                CollectionAsserts.assertContents(actual, set);
-                CollectionAsserts.assertContents(actual, original);
-            }
-        }
-    }
-
-    @Test
-    public void testRemoveIf() throws Exception {
-        final CollectionSupplier supplier = new CollectionSupplier(SET_CLASSES, SIZE);
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final Set<Integer> original = ((Set<Integer>) test.original);
-            final Set<Integer> set = ((Set<Integer>) test.collection);
-
-            try {
-                set.removeIf(null);
-                fail("expected NPE not thrown");
-            } catch (NullPointerException npe) {}
-            if (test.className.equals("java.util.HashSet")) {
-                CollectionAsserts.assertContentsUnordered(set, original);
-            } else {
-                CollectionAsserts.assertContents(set, original);
-            }
-
-            set.removeIf(pEven);
-            for (int i : set) {
-                assertTrue((i % 2) == 1);
-            }
-            for (int i : original) {
-                if (i % 2 == 1) {
-                    assertTrue(set.contains(i));
-                }
-            }
-            set.removeIf(pOdd);
-            assertTrue(set.isEmpty());
-        }
-    }
-}
--- a/test/java/util/CollectionExtensionMethods/ListExtensionMethodsTest.java	Fri Apr 19 16:26:16 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,486 +0,0 @@
-/*
- * Copyright (c) 2012 Oracle and/or its affiliates. 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Comparators;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Stack;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.Vector;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.lang.reflect.Constructor;
-import java.util.ConcurrentModificationException;
-import java.util.function.Predicate;
-
-/**
- * @test
- * @library testlibrary
- * @build CollectionAsserts CollectionSupplier
- * @run testng ListExtensionMethodsTest
- * @summary Unit tests for extension methods on List
- */
-public class ListExtensionMethodsTest {
-
-    private static final String[] LIST_CLASSES = {
-        "java.util.ArrayList",
-        "java.util.LinkedList",
-        "java.util.Vector",
-        "java.util.concurrent.CopyOnWriteArrayList"
-    };
-
-    private static final String[] LIST_CME_CLASSES = {
-        "java.util.ArrayList",
-        "java.util.Vector"
-    };
-
-    private static final Predicate<Integer> pEven = x -> 0 == x % 2;
-    private static final Predicate<Integer> pOdd = x -> 1 == x % 2;
-
-    private static final Comparator<Integer> BIT_COUNT_COMPARATOR =
-            (x, y) -> Integer.bitCount(x) - Integer.bitCount(y);
-
-    private static final Comparator<AtomicInteger> ATOMIC_INTEGER_COMPARATOR =
-            (x, y) -> x.intValue() - y.intValue();
-
-    private static final int SIZE = 100;
-    private static final int SUBLIST_FROM = 2;
-    private static final int SUBLIST_TO = SIZE - SUBLIST_FROM;
-    private static final int SUBLIST_SIZE = SUBLIST_TO - SUBLIST_FROM;
-
-    private static interface Callback {
-        void call(List<Integer> list);
-    }
-
-    // call the callback for each recursive subList
-    private void trimmedSubList(final List<Integer> list, final Callback callback) {
-        int size = list.size();
-        if (size > 1) {
-            // trim 1 element from both ends
-            final List<Integer> subList = list.subList(1, size - 1);
-            callback.call(subList);
-            trimmedSubList(subList, callback);
-        }
-    }
-
-    @DataProvider(name="listProvider")
-    public static Object[][] listCases() {
-        final List<Object[]> cases = new LinkedList<>();
-        cases.add(new Object[] { new ArrayList<>() });
-        cases.add(new Object[] { new LinkedList<>() });
-        cases.add(new Object[] { new Vector<>() });
-        cases.add(new Object[] { new Stack<>() });
-        cases.add(new Object[] { new CopyOnWriteArrayList<>() });
-
-        cases.add(new Object[] { new ArrayList(){{add(42);}} });
-        cases.add(new Object[] { new LinkedList(){{add(42);}} });
-        cases.add(new Object[] { new Vector(){{add(42);}} });
-        cases.add(new Object[] { new Stack(){{add(42);}} });
-        cases.add(new Object[] { new CopyOnWriteArrayList(){{add(42);}} });
-        return cases.toArray(new Object[0][cases.size()]);
-    }
-
-    @Test(dataProvider = "listProvider")
-    public void testProvidedWithNull(final List<Integer> list) throws Exception {
-        try {
-            list.forEach(null);
-            fail("expected NPE not thrown");
-        } catch (NullPointerException npe) {}
-        try {
-            list.replaceAll(null);
-            fail("expected NPE not thrown");
-        } catch (NullPointerException npe) {}
-        try {
-            list.removeIf(null);
-            fail("expected NPE not thrown");
-        } catch (NullPointerException npe) {}
-    }
-
-    @Test
-    public void testForEach() throws Exception {
-        final CollectionSupplier supplier = new CollectionSupplier(LIST_CLASSES, SIZE);
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> original = ((List<Integer>) test.original);
-            final List<Integer> list = ((List<Integer>) test.collection);
-        }
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> original = ((List<Integer>) test.original);
-            final List<Integer> list = ((List<Integer>) test.collection);
-
-            try {
-                list.forEach(null);
-                fail("expected NPE not thrown");
-            } catch (NullPointerException npe) {}
-            CollectionAsserts.assertContents(list, original);
-
-            final List<Integer> actual = new LinkedList<>();
-            list.forEach(actual::add);
-            CollectionAsserts.assertContents(actual, list);
-            CollectionAsserts.assertContents(actual, original);
-
-            if (original.size() > SUBLIST_SIZE) {
-                final List<Integer> subList = original.subList(SUBLIST_FROM, SUBLIST_TO);
-                final List<Integer> actualSubList = new LinkedList<>();
-                subList.forEach(actualSubList::add);
-                assertEquals(actualSubList.size(), SUBLIST_SIZE);
-                for (int i = 0; i < SUBLIST_SIZE; i++) {
-                    assertEquals(actualSubList.get(i), original.get(i + SUBLIST_FROM));
-                }
-            }
-
-            trimmedSubList(list, new Callback() {
-                @Override
-                public void call(final List<Integer> list) {
-                    final List<Integer> actual = new LinkedList<>();
-                    list.forEach(actual::add);
-                    CollectionAsserts.assertContents(actual, list);
-                }
-            });
-        }
-    }
-
-    @Test
-    public void testRemoveIf() throws Exception {
-        final CollectionSupplier supplier = new CollectionSupplier(LIST_CLASSES, SIZE);
-
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> original = ((List<Integer>) test.original);
-            final List<Integer> list = ((List<Integer>) test.collection);
-
-            try {
-                list.removeIf(null);
-                fail("expected NPE not thrown");
-            } catch (NullPointerException npe) {}
-            CollectionAsserts.assertContents(list, original);
-
-            final AtomicInteger offset = new AtomicInteger(1);
-            while (list.size() > 0) {
-                removeFirst(original, list, offset);
-            }
-        }
-
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> original = ((List<Integer>) test.original);
-            final List<Integer> list = ((List<Integer>) test.collection);
-            list.removeIf(pOdd);
-            for (int i : list) {
-                assertTrue((i % 2) == 0);
-            }
-            for (int i : original) {
-                if (i % 2 == 0) {
-                    assertTrue(list.contains(i));
-                }
-            }
-            list.removeIf(pEven);
-            assertTrue(list.isEmpty());
-        }
-
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> original = ((List<Integer>) test.original);
-            final List<Integer> list = ((List<Integer>) test.collection);
-            final List<Integer> listCopy = new ArrayList<>(list);
-            if (original.size() > SUBLIST_SIZE) {
-                final List<Integer> subList = list.subList(SUBLIST_FROM, SUBLIST_TO);
-                final List<Integer> subListCopy = new ArrayList<>(subList);
-                listCopy.removeAll(subList);
-                subList.removeIf(pOdd);
-                for (int i : subList) {
-                    assertTrue((i % 2) == 0);
-                }
-                for (int i : subListCopy) {
-                    if (i % 2 == 0) {
-                        assertTrue(subList.contains(i));
-                    } else {
-                        assertFalse(subList.contains(i));
-                    }
-                }
-                subList.removeIf(pEven);
-                assertTrue(subList.isEmpty());
-                // elements outside the view should remain
-                CollectionAsserts.assertContents(list, listCopy);
-            }
-        }
-
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> list = ((List<Integer>) test.collection);
-            trimmedSubList(list, new Callback() {
-                @Override
-                public void call(final List<Integer> list) {
-                    final List<Integer> copy = new ArrayList<>(list);
-                    list.removeIf(pOdd);
-                    for (int i : list) {
-                        assertTrue((i % 2) == 0);
-                    }
-                    for (int i : copy) {
-                        if (i % 2 == 0) {
-                            assertTrue(list.contains(i));
-                        } else {
-                            assertFalse(list.contains(i));
-                        }
-                    }
-                }
-            });
-        }
-    }
-
-    // remove the first element
-    private void removeFirst(final List<Integer> original, final List<Integer> list, final AtomicInteger offset) {
-        final AtomicBoolean first = new AtomicBoolean(true);
-        list.removeIf(x -> first.getAndSet(false));
-        CollectionAsserts.assertContents(original.subList(offset.getAndIncrement(), original.size()), list);
-    }
-
-    @Test
-    public void testReplaceAll() throws Exception {
-        final int scale = 3;
-        final CollectionSupplier supplier = new CollectionSupplier(LIST_CLASSES, SIZE);
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> original = ((List<Integer>) test.original);
-            final List<Integer> list = ((List<Integer>) test.collection);
-
-            try {
-                list.replaceAll(null);
-                fail("expected NPE not thrown");
-            } catch (NullPointerException npe) {}
-            CollectionAsserts.assertContents(list, original);
-
-            list.replaceAll(x -> scale * x);
-            for (int i=0; i < original.size(); i++) {
-                assertTrue(list.get(i) == (scale * original.get(i)), "mismatch at index " + i);
-            }
-
-            if (original.size() > SUBLIST_SIZE) {
-                final List<Integer> subList = list.subList(SUBLIST_FROM, SUBLIST_TO);
-                subList.replaceAll(x -> x + 1);
-                // verify elements in view [from, to) were replaced
-                for (int i = 0; i < SUBLIST_SIZE; i++) {
-                    assertTrue(subList.get(i) == ((scale * original.get(i + SUBLIST_FROM)) + 1),
-                            "mismatch at sublist index " + i);
-                }
-                // verify that elements [0, from) remain unmodified
-                for (int i = 0; i < SUBLIST_FROM; i++) {
-                    assertTrue(list.get(i) == (scale * original.get(i)),
-                            "mismatch at original index " + i);
-                }
-                // verify that elements [to, size) remain unmodified
-                for (int i = SUBLIST_TO; i < list.size(); i++) {
-                    assertTrue(list.get(i) == (scale * original.get(i)),
-                            "mismatch at original index " + i);
-                }
-            }
-        }
-
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> list = ((List<Integer>) test.collection);
-            trimmedSubList(list, new Callback() {
-                @Override
-                public void call(final List<Integer> list) {
-                    final List<Integer> copy = new ArrayList<>(list);
-                    final int offset = 5;
-                    list.replaceAll(x -> offset + x);
-                    for (int i=0; i < copy.size(); i++) {
-                        assertTrue(list.get(i) == (offset + copy.get(i)), "mismatch at index " + i);
-                    }
-                }
-            });
-        }
-    }
-
-    @Test
-    public void testSort() throws Exception {
-        final CollectionSupplier supplier = new CollectionSupplier(LIST_CLASSES, SIZE);
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> original = ((List<Integer>) test.original);
-            final List<Integer> list = ((List<Integer>) test.collection);
-            CollectionSupplier.shuffle(list);
-            list.sort(Integer::compare);
-            CollectionAsserts.assertSorted(list, Integer::compare);
-            if (test.name.startsWith("reverse")) {
-                Collections.reverse(list);
-            }
-            CollectionAsserts.assertContents(list, original);
-
-            CollectionSupplier.shuffle(list);
-            list.sort(null);
-            CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder());
-            if (test.name.startsWith("reverse")) {
-                Collections.reverse(list);
-            }
-            CollectionAsserts.assertContents(list, original);
-
-            CollectionSupplier.shuffle(list);
-            list.sort(Comparators.<Integer>naturalOrder());
-            CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder());
-            if (test.name.startsWith("reverse")) {
-                Collections.reverse(list);
-            }
-            CollectionAsserts.assertContents(list, original);
-
-            CollectionSupplier.shuffle(list);
-            list.sort(Comparators.<Integer>reverseOrder());
-            CollectionAsserts.assertSorted(list, Comparators.<Integer>reverseOrder());
-            if (!test.name.startsWith("reverse")) {
-                Collections.reverse(list);
-            }
-            CollectionAsserts.assertContents(list, original);
-
-            CollectionSupplier.shuffle(list);
-            list.sort(BIT_COUNT_COMPARATOR);
-            CollectionAsserts.assertSorted(list, BIT_COUNT_COMPARATOR);
-            // check sort by verifying that bitCount increases and never drops
-            int minBitCount = 0;
-            int bitCount = 0;
-            for (final Integer i : list) {
-                bitCount = Integer.bitCount(i);
-                assertTrue(bitCount >= minBitCount);
-                minBitCount = bitCount;
-            }
-
-            @SuppressWarnings("unchecked")
-            final Class<? extends List<AtomicInteger>> type =
-                    (Class<? extends List<AtomicInteger>>) Class.forName(test.className);
-            final Constructor<? extends List<AtomicInteger>> defaultConstructor = type.getConstructor();
-            final List<AtomicInteger> incomparables = (List<AtomicInteger>) defaultConstructor.newInstance();
-
-            for (int i=0; i < test.original.size(); i++) {
-                incomparables.add(new AtomicInteger(i));
-            }
-            CollectionSupplier.shuffle(incomparables);
-            incomparables.sort(ATOMIC_INTEGER_COMPARATOR);
-            for (int i=0; i < test.original.size(); i++) {
-                assertEquals(i, incomparables.get(i).intValue());
-            }
-
-            if (original.size() > SUBLIST_SIZE) {
-                final List<Integer> copy = new ArrayList<>(list);
-                final List<Integer> subList = list.subList(SUBLIST_FROM, SUBLIST_TO);
-                CollectionSupplier.shuffle(subList);
-                subList.sort(Comparators.<Integer>naturalOrder());
-                CollectionAsserts.assertSorted(subList, Comparators.<Integer>naturalOrder());
-                // verify that elements [0, from) remain unmodified
-                for (int i = 0; i < SUBLIST_FROM; i++) {
-                    assertTrue(list.get(i) == copy.get(i),
-                            "mismatch at index " + i);
-                }
-                // verify that elements [to, size) remain unmodified
-                for (int i = SUBLIST_TO; i < list.size(); i++) {
-                    assertTrue(list.get(i) == copy.get(i),
-                            "mismatch at index " + i);
-                }
-            }
-        }
-
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> list = ((List<Integer>) test.collection);
-            trimmedSubList(list, new Callback() {
-                @Override
-                public void call(final List<Integer> list) {
-                    final List<Integer> copy = new ArrayList<>(list);
-                    CollectionSupplier.shuffle(list);
-                    list.sort(Comparators.<Integer>naturalOrder());
-                    CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder());
-                }
-            });
-        }
-    }
-
-    @Test
-    public void testRemoveIfThrowsCME() throws Exception {
-        final CollectionSupplier supplier = new CollectionSupplier(LIST_CME_CLASSES, SIZE);
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> list = ((List<Integer>) test.collection);
-            if (list.size() <= 1) {
-                continue;
-            }
-            boolean gotException = false;
-            try {
-                // bad predicate that modifies its list, should throw CME
-                list.removeIf((x) -> {return list.add(x);});
-            } catch (ConcurrentModificationException cme) {
-                gotException = true;
-            }
-            if (!gotException) {
-                fail("expected CME was not thrown from " + test);
-            }
-        }
-    }
-
-    @Test
-    public void testReplaceAllThrowsCME() throws Exception {
-        final CollectionSupplier supplier = new CollectionSupplier(LIST_CME_CLASSES, SIZE);
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> list = ((List<Integer>) test.collection);
-            if (list.size() <= 1) {
-                continue;
-            }
-            boolean gotException = false;
-            try {
-                // bad predicate that modifies its list, should throw CME
-                list.replaceAll(x -> {int n = 3 * x; list.add(n); return n;});
-            } catch (ConcurrentModificationException cme) {
-                gotException = true;
-            }
-            if (!gotException) {
-                fail("expected CME was not thrown from " + test);
-            }
-        }
-    }
-
-    @Test
-    public void testSortThrowsCME() throws Exception {
-        final CollectionSupplier supplier = new CollectionSupplier(LIST_CME_CLASSES, SIZE);
-        for (final CollectionSupplier.TestCase test : supplier.get()) {
-            final List<Integer> list = ((List<Integer>) test.collection);
-            if (list.size() <= 1) {
-                continue;
-            }
-            boolean gotException = false;
-            try {
-                // bad predicate that modifies its list, should throw CME
-                list.sort((x, y) -> {list.add(x); return x - y;});
-            } catch (ConcurrentModificationException cme) {
-                gotException = true;
-            }
-            if (!gotException) {
-                fail("expected CME was not thrown from " + test);
-            }
-        }
-    }
-
-}
--- a/test/java/util/CollectionExtensionMethods/Wrappers.java	Fri Apr 19 16:26:16 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @run testng Wrappers
- * @summary Unit tests for wrapping classes should delegate default methods
- */
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.testng.annotations.Test;
-import org.testng.annotations.DataProvider;
-
-import static org.testng.Assert.assertFalse;
-
-@Test(groups = "unit")
-public class Wrappers {
-    static Object[][] collections;
-
-    @DataProvider(name="collections")
-    public static Object[][] collectionCases() {
-        if (collections != null) {
-            return collections;
-        }
-
-        List<Object[]> cases = new ArrayList<>();
-        LinkedList<Integer> seedList = new LinkedList<>();
-        TreeSet<Integer> seedSet = new TreeSet<>();
-        TreeMap<Integer, Integer> seedMap = new TreeMap<>();
-
-        for (int i = 1; i <= 10; i++) {
-            seedList.add(i);
-            seedSet.add(i);
-            seedMap.put(i, i);
-        }
-
-        cases.add(new Object[] { Collections.unmodifiableCollection(seedList) });
-        cases.add(new Object[] { Collections.unmodifiableList(seedList) });
-        cases.add(new Object[] { Collections.unmodifiableSet(seedSet) });
-        cases.add(new Object[] { Collections.unmodifiableSortedSet(seedSet) });
-
-        // As sets from map also need to be unmodifiable, thus a wrapping
-        // layer exist and should not have default methods
-        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).entrySet() });
-        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).keySet() });
-        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).values() });
-        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).entrySet() });
-        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).keySet() });
-        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).values() });
-
-        // Synchronized
-        cases.add(new Object[] { Collections.synchronizedCollection(seedList) });
-        cases.add(new Object[] { Collections.synchronizedList(seedList) });
-        cases.add(new Object[] { Collections.synchronizedSet(seedSet) });
-        cases.add(new Object[] { Collections.synchronizedSortedSet(seedSet) });
-
-        // As sets from map also need to be synchronized on the map, thus a
-        // wrapping layer exist and should not have default methods
-        cases.add(new Object[] { Collections.synchronizedMap(seedMap).entrySet() });
-        cases.add(new Object[] { Collections.synchronizedMap(seedMap).keySet() });
-        cases.add(new Object[] { Collections.synchronizedMap(seedMap).values() });
-        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).entrySet() });
-        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).keySet() });
-        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).values() });
-
-        // Checked
-        cases.add(new Object[] { Collections.checkedCollection(seedList, Integer.class) });
-        cases.add(new Object[] { Collections.checkedList(seedList, Integer.class) });
-        cases.add(new Object[] { Collections.checkedSet(seedSet, Integer.class) });
-        cases.add(new Object[] { Collections.checkedSortedSet(seedSet, Integer.class) });
-        cases.add(new Object[] { Collections.checkedQueue(seedList, Integer.class) });
-
-        // asLifoQueue is another wrapper
-        cases.add(new Object[] { Collections.asLifoQueue(seedList) });
-
-        collections = cases.toArray(new Object[0][]);
-        return collections;
-    }
-
-    static Method[] defaultMethods;
-
-    static {
-        ArrayList<Method> list = new ArrayList<>();
-        Method[] methods = Collection.class.getMethods();
-        for (Method m: methods) {
-            if (m.isDefault()) {
-                list.add(m);
-            }
-        }
-        defaultMethods = list.toArray(new Method[0]);
-    }
-
-    @Test(dataProvider = "collections")
-    public static void testAllDefaultMethodsOverrided(Collection c) throws NoSuchMethodException {
-        Class cls = c.getClass();
-        for (Method m: defaultMethods) {
-            Method m2 = cls.getMethod(m.getName(), m.getParameterTypes());
-            // default had been override
-            assertFalse(m2.isDefault(), cls.getCanonicalName());
-        }
-    }
-}
\ No newline at end of file
--- a/test/java/util/CollectionExtensionMethods/testlibrary/CollectionAsserts.java	Fri Apr 19 16:26:16 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-/**
- * @library
- * CollectionAssert -- assertion methods for lambda test cases
- */
-public class CollectionAsserts {
-
-    public static void assertCountSum(Iterable<? super Integer> it, int count, int sum) {
-        assertCountSum(it.iterator(), count, sum);
-    }
-
-    public static void assertCountSum(Iterator<? super Integer> it, int count, int sum) {
-        int c = 0;
-        int s = 0;
-        while (it.hasNext()) {
-            int i = (Integer) it.next();
-            c++;
-            s += i;
-        }
-
-        assertEquals(c, count);
-        assertEquals(s, sum);
-    }
-
-    public static void assertConcat(Iterator<Character> it, String result) {
-        StringBuilder sb = new StringBuilder();
-        while (it.hasNext()) {
-            sb.append(it.next());
-        }
-
-        assertEquals(result, sb.toString());
-    }
-
-    public static<T extends Comparable<? super T>> void assertSorted(Iterator<T> i) {
-        if (!i.hasNext())
-            return;
-        T last = i.next();
-        while (i.hasNext()) {
-            T t = i.next();
-            assertTrue(last.compareTo(t) <= 0);
-            assertTrue(t.compareTo(last) >= 0);
-            last = t;
-        }
-    }
-
-    public static<T> void assertSorted(Iterator<T> i, Comparator<? super T> comp) {
-        if (!i.hasNext())
-            return;
-        T last = i.next();
-        while (i.hasNext()) {
-            T t = i.next();
-            assertTrue(comp.compare(last, t) <= 0);
-            assertTrue(comp.compare(t, last) >= 0);
-            last = t;
-        }
-    }
-
-    public static<T extends Comparable<? super T>> void assertSorted(Iterable<T> iter) {
-        assertSorted(iter.iterator());
-    }
-
-    public static<T> void assertSorted(Iterable<T> iter, Comparator<? super T> comp) {
-        assertSorted(iter.iterator(), comp);
-    }
-
-    public static <T> void assertUnique(Iterable<T> iter) {
-        assertUnique(iter.iterator());
-    }
-
-    public static<T> void assertUnique(Iterator<T> iter) {
-        if (!iter.hasNext()) {
-            return;
-        }
-
-        Set<T> uniq = new HashSet<>();
-        while(iter.hasNext()) {
-            T each = iter.next();
-            assertTrue(!uniq.contains(each));
-            uniq.add(each);
-        }
-    }
-
-    public static<T> void assertContents(Iterable<T> actual, Iterable<T> expected) {
-        assertContents(actual.iterator(), expected.iterator());
-    }
-
-    public static<T> void assertContents(Iterator<T> actual, Iterator<T> expected) {
-        List<T> history = new ArrayList<>();
-
-        while (expected.hasNext()) {
-            if (!actual.hasNext()) {
-                List<T> expectedData = new ArrayList<>(history);
-                while (expected.hasNext())
-                    expectedData.add(expected.next());
-                fail(String.format("Premature end of data; expected=%s, found=%s", expectedData, history));
-            }
-            T a = actual.next();
-            T e = expected.next();
-            history.add(a);
-
-            if (!Objects.equals(a, e))
-                fail(String.format("Data mismatch; preceding=%s, nextExpected=%s, nextFound=%s", history, e, a));
-        }
-        if (actual.hasNext()) {
-            List<T> rest = new ArrayList<>();
-            while (actual.hasNext())
-                rest.add(actual.next());
-            fail(String.format("Unexpected data %s after %s", rest, history));
-        }
-    }
-
-    @SafeVarargs
-    @SuppressWarnings("varargs")
-    public static<T> void assertContents(Iterator<T> actual, T... expected) {
-        assertContents(actual, Arrays.asList(expected).iterator());
-    }
-
-    public static <T> boolean equalsContentsUnordered(Iterable<T> a, Iterable<T> b) {
-        Set<T> sa = new HashSet<>();
-        for (T t : a) {
-            sa.add(t);
-        }
-
-        Set<T> sb = new HashSet<>();
-        for (T t : b) {
-            sb.add(t);
-        }
-
-        return Objects.equals(sa, sb);
-    }
-
-    public static<T extends Comparable<? super T>> void assertContentsUnordered(Iterable<T> actual, Iterable<T> expected) {
-        ArrayList<T> one = new ArrayList<>();
-        for (T t : actual)
-            one.add(t);
-        ArrayList<T> two = new ArrayList<>();
-        for (T t : expected)
-            two.add(t);
-        Collections.sort(one);
-        Collections.sort(two);
-        assertContents(one, two);
-    }
-
-    static <T> void assertSplitContents(Iterable<Iterable<T>> splits, Iterable<T> list) {
-        Iterator<Iterable<T>> mI = splits.iterator();
-        Iterator<T> pI = null;
-        Iterator<T> lI = list.iterator();
-
-        while (lI.hasNext()) {
-            if (pI == null)
-                pI = mI.next().iterator();
-            while (!pI.hasNext()) {
-                if (!mI.hasNext()) {
-                    break;
-                }
-                else {
-                    pI = mI.next().iterator();
-                }
-            }
-            assertTrue(pI.hasNext());
-            T pT = pI.next();
-            T lT = lI.next();
-            assertEquals(pT, lT);
-        }
-
-        if (pI != null) {
-            assertTrue(!pI.hasNext());
-        }
-
-        while(mI.hasNext()) {
-            pI = mI.next().iterator();
-            assertTrue(!pI.hasNext());
-        }
-    }
-}
--- a/test/java/util/CollectionExtensionMethods/testlibrary/CollectionSupplier.java	Fri Apr 19 16:26:16 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 2012 Oracle and/or its affiliates. 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.lang.ArrayStoreException;
-import java.lang.AssertionError;
-import java.lang.Exception;
-import java.lang.Integer;
-import java.lang.Iterable;
-import java.lang.Override;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
-
-import org.testng.annotations.Test;
-import org.testng.TestException;
-
-import static org.testng.Assert.assertTrue;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-
-/**
- * @library
- * @summary A Supplier of test cases for Collection tests
- */
-public final class CollectionSupplier implements Supplier<Iterable<CollectionSupplier.TestCase>> {
-
-    private final String[] classNames;
-    private final int size;
-
-    /**
-     * A Collection test case.
-     */
-    public static final class TestCase {
-
-        /**
-         * The name of the test case.
-         */
-        public final String name;
-
-        /**
-         * Class name of the instantiated Collection.
-         */
-        public final String className;
-
-        /**
-         * Unmodifiable reference collection, useful for comparisons.
-         */
-        public final Collection<Integer> original;
-
-        /**
-         * A modifiable test collection.
-         */
-        public final Collection<Integer> collection;
-
-        /**
-         * Create a Collection test case.
-         * @param name name of the test case
-         * @param className class name of the instantiated collection
-         * @param original reference collection
-         * @param collection the modifiable test collection
-         */
-        public TestCase(String name, String className,
-                Collection<Integer> original, Collection<Integer> collection) {
-            this.name = name;
-            this.className = className;
-            this.original =
-                    List.class.isAssignableFrom(original.getClass()) ?
-                    Collections.unmodifiableList((List<Integer>) original) :
-                    Set.class.isAssignableFrom(original.getClass()) ?
-                    Collections.unmodifiableSet((Set<Integer>) original) :
-                    Collections.unmodifiableCollection(original);
-            this.collection = collection;
-        }
-
-        @Override
-        public String toString() {
-            return name + " " + className +
-                    "\n original: " + original +
-                    "\n   target: " + collection;
-        }
-    }
-
-    /**
-     * Shuffle a list using a PRNG with known seed for repeatability
-     * @param list the list to be shuffled
-     */
-    public static <E> void shuffle(final List<E> list) {
-        // PRNG with known seed for repeatable tests
-        final Random prng = new Random(13);
-        final int size = list.size();
-        for (int i=0; i < size; i++) {
-            // random index in interval [i, size)
-            final int j = i + prng.nextInt(size - i);
-            // swap elements at indices i & j
-            final E e = list.get(i);
-            list.set(i, list.get(j));
-            list.set(j, e);
-        }
-    }
-
-    /**
-     * Create a {@code Supplier} that creates instances of specified collection
-     * classes of specified length.
-     *
-     * @param classNames class names that implement {@code Collection}
-     * @param size the desired size of each collection
-     */
-    public CollectionSupplier(String[] classNames, int size) {
-        this.classNames = Arrays.copyOf(classNames, classNames.length);
-        this.size = size;
-    }
-
-    @Override
-    public Iterable<TestCase> get() {
-        try {
-            return getThrows();
-        } catch (Exception e) {
-            throw new TestException(e);
-        }
-    }
-
-    private Iterable<TestCase> getThrows() throws Exception {
-        final Collection<TestCase> collections = new LinkedList<>();
-        for (final String className : classNames) {
-            @SuppressWarnings("unchecked")
-            final Class<? extends Collection<Integer>> type =
-                    (Class<? extends Collection<Integer>>) Class.forName(className);
-            final Constructor<? extends Collection<Integer>>
-                    defaultConstructor = type.getConstructor();
-            final Constructor<? extends Collection<Integer>>
-                    copyConstructor = type.getConstructor(Collection.class);
-
-            final Collection<Integer> empty = defaultConstructor.newInstance();
-            collections.add(new TestCase("empty",
-                    className,
-                    copyConstructor.newInstance(empty),
-                    empty));
-
-            final Collection<Integer> single = defaultConstructor.newInstance();
-            single.add(42);
-            collections.add(new TestCase("single",
-                    className,
-                    copyConstructor.newInstance(single),
-                    single));
-
-            final Collection<Integer> regular = defaultConstructor.newInstance();
-            for (int i=0; i < size; i++) {
-                regular.add(i);
-            }
-            collections.add(new TestCase("regular",
-                    className,
-                    copyConstructor.newInstance(regular),
-                    regular));
-
-            final Collection<Integer> reverse = defaultConstructor.newInstance();
-            for (int i=size; i >= 0; i--) {
-                reverse.add(i);
-            }
-            collections.add(new TestCase("reverse",
-                    className,
-                    copyConstructor.newInstance(reverse),
-                    reverse));
-
-            final Collection<Integer> odds = defaultConstructor.newInstance();
-            for (int i=0; i < size; i++) {
-                odds.add((i * 2) + 1);
-            }
-            collections.add(new TestCase("odds",
-                    className,
-                    copyConstructor.newInstance(odds),
-                    odds));
-
-            final Collection<Integer> evens = defaultConstructor.newInstance();
-            for (int i=0; i < size; i++) {
-                evens.add(i * 2);
-            }
-            collections.add(new TestCase("evens",
-                    className,
-                    copyConstructor.newInstance(evens),
-                    evens));
-
-            final Collection<Integer> fibonacci = defaultConstructor.newInstance();
-            int prev2 = 0;
-            int prev1 = 1;
-            for (int i=0; i < size; i++) {
-                final int n = prev1 + prev2;
-                if (n < 0) { // stop on overflow
-                    break;
-                }
-                fibonacci.add(n);
-                prev2 = prev1;
-                prev1 = n;
-            }
-            collections.add(new TestCase("fibonacci",
-                    className,
-                    copyConstructor.newInstance(fibonacci),
-                    fibonacci));
-
-            // variants where the size of the backing storage != reported size
-            // created by removing half of the elements
-
-            final Collection<Integer> emptyWithSlack = defaultConstructor.newInstance();
-            emptyWithSlack.add(42);
-            assertTrue(emptyWithSlack.remove(42));
-            collections.add(new TestCase("emptyWithSlack",
-                    className,
-                    copyConstructor.newInstance(emptyWithSlack),
-                    emptyWithSlack));
-
-            final Collection<Integer> singleWithSlack = defaultConstructor.newInstance();
-            singleWithSlack.add(42);
-            singleWithSlack.add(43);
-            assertTrue(singleWithSlack.remove(43));
-            collections.add(new TestCase("singleWithSlack",
-                    className,
-                    copyConstructor.newInstance(singleWithSlack),
-                    singleWithSlack));
-
-            final Collection<Integer> regularWithSlack = defaultConstructor.newInstance();
-            for (int i=0; i < (2 * size); i++) {
-                regularWithSlack.add(i);
-            }
-            assertTrue(regularWithSlack.removeIf((x) -> {return x >= size;}));
-            collections.add(new TestCase("regularWithSlack",
-                    className,
-                    copyConstructor.newInstance(regularWithSlack),
-                    regularWithSlack));
-
-            final Collection<Integer> reverseWithSlack = defaultConstructor.newInstance();
-            for (int i=2 * size; i >= 0; i--) {
-                reverseWithSlack.add(i);
-            }
-            assertTrue(reverseWithSlack.removeIf((x) -> {return x < size;}));
-            collections.add(new TestCase("reverseWithSlack",
-                    className,
-                    copyConstructor.newInstance(reverseWithSlack),
-                    reverseWithSlack));
-
-            final Collection<Integer> oddsWithSlack = defaultConstructor.newInstance();
-            for (int i = 0; i < 2 * size; i++) {
-                oddsWithSlack.add((i * 2) + 1);
-            }
-            assertTrue(oddsWithSlack.removeIf((x) -> {return x >= size;}));
-            collections.add(new TestCase("oddsWithSlack",
-                    className,
-                    copyConstructor.newInstance(oddsWithSlack),
-                    oddsWithSlack));
-
-            final Collection<Integer> evensWithSlack = defaultConstructor.newInstance();
-            for (int i = 0; i < 2 * size; i++) {
-                evensWithSlack.add(i * 2);
-            }
-            assertTrue(evensWithSlack.removeIf((x) -> {return x >= size;}));
-            collections.add(new TestCase("evensWithSlack",
-                    className,
-                    copyConstructor.newInstance(evensWithSlack),
-                    evensWithSlack));
-
-            final Collection<Integer> fibonacciWithSlack = defaultConstructor.newInstance();
-            prev2 = 0;
-            prev1 = 1;
-            for (int i=0; i < size; i++) {
-                final int n = prev1 + prev2;
-                if (n < 0) { // stop on overflow
-                    break;
-                }
-                fibonacciWithSlack.add(n);
-                prev2 = prev1;
-                prev1 = n;
-            }
-            assertTrue(fibonacciWithSlack.removeIf((x) -> {return x < 20;}));
-            collections.add(new TestCase("fibonacciWithSlack",
-                    className,
-                    copyConstructor.newInstance(fibonacciWithSlack),
-                    fibonacciWithSlack));
-
-        }
-
-        return collections;
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Collections/Wrappers.java	Fri Apr 19 14:45:28 2013 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @run testng Wrappers
+ * @summary Unit tests for wrapping classes should delegate to default methods
+ */
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+
+import static org.testng.Assert.assertFalse;
+
+@Test(groups = "unit")
+public class Wrappers {
+    static Object[][] collections;
+
+    @DataProvider(name="collections")
+    public static Object[][] collectionCases() {
+        if (collections != null) {
+            return collections;
+        }
+
+        List<Object[]> cases = new ArrayList<>();
+        LinkedList<Integer> seedList = new LinkedList<>();
+        TreeSet<Integer> seedSet = new TreeSet<>();
+        TreeMap<Integer, Integer> seedMap = new TreeMap<>();
+
+        for (int i = 1; i <= 10; i++) {
+            seedList.add(i);
+            seedSet.add(i);
+            seedMap.put(i, i);
+        }
+
+        cases.add(new Object[] { Collections.unmodifiableCollection(seedList) });
+        cases.add(new Object[] { Collections.unmodifiableList(seedList) });
+        cases.add(new Object[] { Collections.unmodifiableSet(seedSet) });
+        cases.add(new Object[] { Collections.unmodifiableSortedSet(seedSet) });
+
+        // As sets from map also need to be unmodifiable, thus a wrapping
+        // layer exist and should not have default methods
+        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).values() });
+        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).values() });
+
+        // Synchronized
+        cases.add(new Object[] { Collections.synchronizedCollection(seedList) });
+        cases.add(new Object[] { Collections.synchronizedList(seedList) });
+        cases.add(new Object[] { Collections.synchronizedSet(seedSet) });
+        cases.add(new Object[] { Collections.synchronizedSortedSet(seedSet) });
+
+        // As sets from map also need to be synchronized on the map, thus a
+        // wrapping layer exist and should not have default methods
+        cases.add(new Object[] { Collections.synchronizedMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.synchronizedMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.synchronizedMap(seedMap).values() });
+        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).values() });
+
+        // Checked
+        cases.add(new Object[] { Collections.checkedCollection(seedList, Integer.class) });
+        cases.add(new Object[] { Collections.checkedList(seedList, Integer.class) });
+        cases.add(new Object[] { Collections.checkedSet(seedSet, Integer.class) });
+        cases.add(new Object[] { Collections.checkedSortedSet(seedSet, Integer.class) });
+        cases.add(new Object[] { Collections.checkedQueue(seedList, Integer.class) });
+
+        // asLifoQueue is another wrapper
+        cases.add(new Object[] { Collections.asLifoQueue(seedList) });
+
+        collections = cases.toArray(new Object[0][]);
+        return collections;
+    }
+
+    static Method[] defaultMethods;
+
+    static {
+        ArrayList<Method> list = new ArrayList<>();
+        Method[] methods = Collection.class.getMethods();
+        for (Method m: methods) {
+            if (m.isDefault()) {
+                list.add(m);
+            }
+        }
+        defaultMethods = list.toArray(new Method[0]);
+    }
+
+    @Test(dataProvider = "collections")
+    public static void testAllDefaultMethodsOverridden(Collection c) throws NoSuchMethodException {
+        Class cls = c.getClass();
+        for (Method m: defaultMethods) {
+            Method m2 = cls.getMethod(m.getName(), m.getParameterTypes());
+            // default had been override
+            assertFalse(m2.isDefault(), cls.getCanonicalName());
+        }
+    }
+}
+