Skip to content
This repository was archived by the owner on Feb 25, 2024. It is now read-only.

Commit 02cb7dd

Browse files
committed
JDK-8060192: Add A[] Collection.toArray(IntFunction<A[]>) [#380]
1 parent de9f225 commit 02cb7dd

File tree

1 file changed

+10
-1
lines changed
  • src/main/java/org/openjdk/tests/java/util

1 file changed

+10
-1
lines changed

src/main/java/org/openjdk/tests/java/util/MOAT.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -98,6 +98,7 @@
9898
import java.lang.reflect.Method;
9999

100100
import java9.lang.Integers;
101+
import java9.util.J8Arrays;
101102
import java9.util.Lists;
102103
import java9.util.Maps;
103104
import java9.util.Objects;
@@ -339,6 +340,7 @@ private static <T> void testEmptyCollection(Collection<T> c) {
339340
equal(c.toString(),"[]");
340341
equal(c.toArray().length, 0);
341342
equal(c.toArray(new Object[0]).length, 0);
343+
equal(J8Arrays.toArray((Collection<Object>) c, Object[]::new).length, 0);
342344
check(c.toArray(new Object[]{42})[0] == null);
343345

344346
Object[] a = new Object[1]; a[0] = Boolean.TRUE;
@@ -616,6 +618,13 @@ private static void checkFunctionalInvariants(Collection<Integer> c) {
616618
check(a.getClass() == Integer[].class);
617619
}
618620

621+
{
622+
Integer[] a = J8Arrays.toArray(c, Integer[]::new);
623+
equal(c.size(), a.length);
624+
check(a.getClass() == Integer[].class);
625+
check(Arrays.equals(c.toArray(new Integer[0]), a));
626+
}
627+
619628
check(c.equals(c));
620629
if (c instanceof Serializable) {
621630
//System.out.printf("Serializing %s%n", c.getClass().getName());

0 commit comments

Comments
 (0)