8015667: Stream.toArray(IntFunction) ArrayStoreException should refer to component type of array
Reviewed-by: smarks
--- a/src/java.base/share/classes/java/util/stream/Stream.java Tue Dec 05 23:14:35 2017 +0100
+++ b/src/java.base/share/classes/java/util/stream/Stream.java Tue Dec 05 15:31:50 2017 -0800
@@ -671,7 +671,8 @@
* <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 @@
* .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);