8015667: Stream.toArray(IntFunction) ArrayStoreException should refer to component type of array

Reviewed-by: smarks
This commit is contained in:
Paul Sandoz 2017-12-05 15:31:50 -08:00
parent 9ddcde90e0
commit ed7a7fb89f

View file

@ -671,7 +671,8 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @return an array containing the elements of this stream
* @return an array, whose {@linkplain Class#getComponentType runtime component
* type} is {@code Object}, containing the elements of this stream
*/
Object[] toArray();
@ -694,13 +695,13 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
* .toArray(Person[]::new);
* }</pre>
*
* @param <A> the element type of the resulting array
* @param <A> the component type of the resulting array
* @param generator a function which produces a new array of the desired
* type and the provided length
* @return an array containing the elements in this stream
* @throws ArrayStoreException if the runtime type of the array returned
* from the array generator is not a supertype of the runtime type of every
* element in this stream
* @throws ArrayStoreException if the runtime type of any element of this
* stream is not assignable to the {@linkplain Class#getComponentType
* runtime component type} of the generated array
*/
<A> A[] toArray(IntFunction<A[]> generator);