JDK-8015667 : Stream.toArray(IntFunction) ArrayStoreException should refer to component type of array
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.stream
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-05-30
  • Updated: 2017-12-18
  • Resolved: 2017-12-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10 b35Fixed
Related Reports
Relates :  
Description
Collection.toArray(T[] ), plus from overriding classes, states:

     * @throws ArrayStoreException if the runtime type of the specified array
     *         is not a supertype of the runtime type of every element in
     *         this collection

 and Stream.toArray(IntFunction<A[]> ) state:

     * @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

Rather than "runtime type" it should more accurately be "component type"

Comments
Collection.toArray(T[]) will be fixed by JDK-8160406. This bug should be left open to handle the change to Stream.toArray(IntFunction).
30-11-2017

Comment from Martin Buchholz: Cleaning up all of those unclear "runtime type" specs in the libraries and jls can be a bit of work. Probably could link to http://docs.oracle.com/javase/specs/jls/se7/html/jls-10.html#jls-10.5 and use the terminology from there """ If the type of the value being assigned is not assignment-compatible (��5.2) with the component type, an ArrayStoreException is thrown. """ but there will always be confusion about "compile-time type" and "runtime type". """Variables have type; objects have class"""
31-05-2013