hg: lambda/lambda/jdk: Stream.toArray(ObjIntFunction<A[]> generator) has a type A that is

Remi Forax forax at univ-mlv.fr
Thu Jan 10 05:51:55 PST 2013


On 01/10/2013 12:14 PM, paul.sandoz at oracle.com wrote:
> Changeset: cf3d033dc114
> Author:    psandoz
> Date:      2013-01-10 12:14 +0100
> URL:       http://hg.openjdk.java.net/lambda/lambda/jdk/rev/cf3d033dc114
>
> Stream.toArray(ObjIntFunction<A[]> generator) has a type A that is
> not bound to the stream element type U (like toArray for Collection).
>
> ! src/share/classes/java/util/stream/ReferencePipeline.java
> ! src/share/classes/java/util/stream/Stream.java
> ! test-ng/tests/org/openjdk/tests/java/util/stream/op/ToArrayOpTest.java
>
>

Paul,
you should change asArray() to take an array of A and not an array of U,
so you can isolate the only unsafe cast which is safe because there is a 
runtime check.

Casting an array of U to an array of A is not the same as casting each 
element of type U to A.

Rémi



More information about the lambda-dev mailing list