Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-24 Thread Stuart Marks
On 11/18/20 3:55 AM, Florian Weimer wrote: I think it's also needed for an efficient null element check in List::copyOf. I have a hunch that with the posted implementation, it would incorrectly produce an immutable list that contains null elements. (Sorry for the delay; oddly, this comment

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-18 Thread Stuart Marks
On Tue, 17 Nov 2020 20:04:58 GMT, Stuart Marks wrote: >>> @plevart wrote: >>> >>> > But the question is how does having a separate CollSer.IMM_LIST_NULLS >>> > type prevent that from happening? >>> >>> When a serialized list with IMM_LIST_NULLS is deserialized on an older JDK, >>> it'll throw

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-18 Thread Remi Forax
- Mail original - > De: "Florian Weimer" > À: "Peter Levart" > Cc: "Stuart Marks" , "core-libs-dev" > > Envoyé: Mercredi 18 Novembre 2020 12:55:02 > Objet: Re: RFR: 8180352: Add Stream.toList() method [v2] > * Peter Levart

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-18 Thread Florian Weimer
* Peter Levart: > But I see that the new  IMM_LIST_NULLS type is needed for one other > thing - the immutable list implementation of that type has different > behavior of indexOf and lastIndexOf methods (it doesn't throw NPE when > null is passed to those methods) so this behavior has to be pre

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-18 Thread Peter Levart
On 11/17/20 9:08 PM, Stuart Marks wrote: @plevart wrote: Yes, but that is JDK16+ vs. JDK15- and not App V1 vs. App V2 thing. If both apps run on JDK16+, there will be no exception. Sure, the IMM_LIST_NULLS tag only helps with serialization compatibility across JDK releases. I would say i

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-17 Thread Stuart Marks
On Tue, 10 Nov 2020 09:34:56 GMT, Peter Levart wrote: >> I can see that having a separate IMM_LIST_NULLS type might be necessary to >> preserve the allows-null/disallows-null behaviour of indexOf and lastIndexOf >> methods... >> >> NOTE ALSO that ListN.equals(o) and ListN.hashCode() are inheri

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-10 Thread Peter Levart
On Sun, 8 Nov 2020 15:55:58 GMT, Peter Levart wrote: >> Hi Stuart, >> >> I would like to discuss the serialization. You introduce new >> CollSer.IMM_LIST_NULLS type of immutable collection. This means that if this >> change goes into JDK16 for example, JDK15 and before will not be able to >>

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-09 Thread Stuart Marks
On Sun, 8 Nov 2020 15:55:58 GMT, Peter Levart wrote: >> Hi Stuart, >> >> I would like to discuss the serialization. You introduce new >> CollSer.IMM_LIST_NULLS type of immutable collection. This means that if this >> change goes into JDK16 for example, JDK15 and before will not be able to >>

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-08 Thread Peter Levart
On Sun, 8 Nov 2020 10:47:08 GMT, Peter Levart wrote: >>> Simon Roberts wrote: >> >>> This discussion of unmodifiable lists brings me back to the thought that >>> there would be good client-side reasons for inserting an UnmodifiableList >>> interface as a parent of LIst, not least because all our

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-08 Thread Peter Levart
On Fri, 6 Nov 2020 03:05:45 GMT, Stuart Marks wrote: >> @ePaul wrote: >> >>> The Stream API works just as well with [third party] collection libraries >>> instead of the java.util ones, just using different collectors. Adding a >>> method which directly returns a java.util.List somewhat couple

Re: RFR: 8180352: Add Stream.toList() method [v2]

2020-11-06 Thread Stuart Marks
> This change introduces a new terminal operation on Stream. This looks like a > convenience method for Stream.collect(Collectors.toList()) or > Stream.collect(Collectors.toUnmodifiableList()), but it's not. Having this > method directly on Stream enables it to do what can't easily by done by a