--- old/test/jdk/java/util/Collection/MOAT.java 2017-12-04 19:06:42.000000000 -0800 +++ new/test/jdk/java/util/Collection/MOAT.java 2017-12-04 19:06:42.000000000 -0800 @@ -363,6 +363,7 @@ equal(c.toString(),"[]"); equal(c.toArray().length, 0); equal(c.toArray(new Object[0]).length, 0); + equal(c.toArray(Object[]::new).length, 0); check(c.toArray(new Object[]{42})[0] == null); Object[] a = new Object[1]; a[0] = Boolean.TRUE; @@ -602,12 +603,6 @@ return true; } - // 6260652: (coll) Arrays.asList(x).toArray().getClass() - // should be Object[].class - // Fixed in jdk9, but not jdk8 ... - static final boolean needToWorkAround6260652 = - Arrays.asList("").toArray().getClass() != Object[].class; - private static void checkFunctionalInvariants(Collection c) { try { checkContainsSelf(c); @@ -626,10 +621,7 @@ } check(c.toArray().length == c.size()); - check(c.toArray().getClass() == Object[].class - || - (needToWorkAround6260652 && - c.getClass().getName().equals("java.util.Arrays$ArrayList"))); + check(c.toArray().getClass() == Object[].class); for (int size : new int[]{0,1,c.size(), c.size()+1}) { Integer[] a = c.toArray(new Integer[size]); check((size > c.size()) || a.length == c.size()); @@ -638,6 +630,13 @@ check(a.getClass() == Integer[].class); } + { + Integer[] a = c.toArray(Integer[]::new); + equal(c.size(), a.length); + check(a.getClass() == Integer[].class); + check(Arrays.equals(c.toArray(new Integer[0]), a)); + } + check(c.equals(c)); if (c instanceof Serializable) { //System.out.printf("Serializing %s%n", c.getClass().getName());