RFR: 8015315: Stream.concat methods

Peter Levart peter.levart at gmail.com
Mon Jul 1 11:36:35 UTC 2013

On 07/01/2013 11:52 AM, Remi Forax wrote:
> On 06/29/2013 02:58 AM, Henry Jen wrote:
>> Hi,
>> Please review the webrev that add concat static method to Stream and
>> primitive Streams.
>> http://cr.openjdk.java.net/~henryjen/ccc/8015315.0/webrev/
>> Cheers,
>> Henry
> Hi Henry,
> I find the the cast to Spliterator<T> in Streams.concat() dubious,
> I can not see how it can be correct, could you explain why this cast 
> is Ok.
> cheers,
> Rémi


I think that if we want to concat say Stream<Integer> with Stream<Long>, 
producing Stream<Number>, there would have to be an unsafe cast 
somewhere. Since Stream<T> API apears to be covariant (like for example 
Iterator<T>), casting Stream<? extends T> to Stream<T> seems to be safe.

Regards, Peter

More information about the core-libs-dev mailing list