Re: RFR: 8180352: Add Stream.toList() method

2021-02-05 Thread Brian Goetz
I have been reading previous threads, the original bug request, and exploring the javadoc and implementation of toList() on Stream in JDK 16. I don’t want to waste time rehashing previous discussions, but I want to understand and prioritize the motivation of this change, and propose what I

RFR: 8180352: Add Stream.toList() method

2021-02-04 Thread Donald Raab
I have been reading previous threads, the original bug request, and exploring the javadoc and implementation of toList() on Stream in JDK 16. I don’t want to waste time rehashing previous discussions, but I want to understand and prioritize the motivation of this change, and propose what I

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

2020-11-30 Thread Stuart Marks
On Wed, 25 Nov 2020 17:14:43 GMT, Peter Levart wrote: >> An alternative with similar performance would be to do a Stream.toArray() >> and then copy that array into new Object[] and then wrap that copy with >> listFromTrustedArrayNullsAllowed(). The difference would be in the >> serialization

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

2020-11-25 Thread Paul Sandoz
On Tue, 24 Nov 2020 07:10:14 GMT, Stuart Marks wrote: >> 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

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

2020-11-25 Thread Peter Levart
On Wed, 25 Nov 2020 14:07:07 GMT, Peter Levart wrote: >> This is the default implementation in the Stream interface, which is >> overridden by an implementation in the ReferencePipeline class, so it will >> rarely be used in normal operation. The ReferencePipeline version (part of >> this

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

2020-11-25 Thread Peter Levart
On Tue, 24 Nov 2020 03:46:38 GMT, Stuart Marks wrote: >> In `ReferencePipeline` class we have: >> >> @Override >> public final Object[] toArray() { >> return toArray(Object[]::new); >> } >> >> @Override >> @SuppressWarnings("unchecked") >> public final A[]

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

2020-11-25 Thread Remi Forax
- Mail original - > De: "Stuart Marks" > À: "core-libs-dev" > Envoyé: Mardi 24 Novembre 2020 08:10:14 > Objet: Re: RFR: 8180352: Add Stream.toList() method [v4] >> This change introduces a new terminal operation on Stream. This looks like a &g

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 [v4]

2020-11-23 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

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

2020-11-23 Thread Stuart Marks
On Sat, 21 Nov 2020 11:02:27 GMT, Rémi Forax wrote: >> Stuart Marks has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Adjust List.copyOf to null-check and copy allowNulls lists. >> Fix equals, hashCode, indexOf, lastIndexOf to handle

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

2020-11-23 Thread Stuart Marks
On Sat, 21 Nov 2020 10:58:49 GMT, Rémi Forax wrote: >> It's an implementation invariant that the internal array be Object[]. Having >> it be something other than Object[] can lead to subtle bugs. See >> [JDK-6260652](https://bugs.openjdk.java.net/browse/JDK-6260652) for example. > > you can

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

2020-11-23 Thread Stuart Marks
On Mon, 23 Nov 2020 14:06:02 GMT, sergus13 wrote: >> This implementation duplicates the array twice, once in this.toArray() and >> once in the constructor of ArrayList that calls toArray() on >> Collections.ArrayList. >> >> I'm sure there is a better way > > In `ReferencePipeline` class we

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

2020-11-23 Thread sergus13
On Sat, 21 Nov 2020 11:22:55 GMT, Rémi Forax wrote: >> `listFromTrustedArrayNullsAllowed` is clearly not an option, as it will >> produce shared-secret leaking (see >> [JDK-8254090](https://bugs.openjdk.java.net/browse/JDK-8254090) for a >> similar case). StreamEx solution is dirty as it

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

2020-11-21 Thread Rémi Forax
On Wed, 4 Nov 2020 09:21:12 GMT, Tagir F. Valeev wrote: >> src/java.base/share/classes/java/util/stream/Stream.java line 1192: >> >>> 1190: @SuppressWarnings("unchecked") >>> 1191: default List toList() { >>> 1192: return (List) Collections.unmodifiableList(new >>>

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

2020-11-21 Thread Rémi Forax
On Wed, 18 Nov 2020 22:20:26 GMT, Stuart Marks wrote: >> 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

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

2020-11-21 Thread Rémi Forax
On Thu, 5 Nov 2020 17:26:48 GMT, Stuart Marks wrote: >> src/java.base/share/classes/java/util/ImmutableCollections.java line 199: >> >>> 197: * safely reused as the List's internal storage, avoiding a >>> defensive copy. Declared >>> 198: * with Object... instead of E... as the

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

2020-11-18 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

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

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

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

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

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

2020-11-08 Thread Alan Snyder
> On Nov 8, 2020, at 3:32 AM, fo...@univ-mlv.fr wrote: > > It's a strawman but the effect is real, the more interfaces you have the less > you can reuse code because the code is written with the wrong interface for > your use case. There are points of compromise. If someone can accept

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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-08 Thread forax
> De: "Alan Snyder" > À: "Remi Forax" > Cc: "Simon Roberts" , "core-libs-dev" > > Envoyé: Vendredi 6 Novembre 2020 18:55:40 > Objet: Re: RFR: 8180352: Add Stream.toList() method Hi Alan, >>> This discussion of unmodifiab

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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-06 Thread Martin Desruisseaux
Le 06/11/2020 à 19:00, Alan Snyder a écrit : (…snip…) But a question that deserves ongoing review is whether Java should support immutable collections using a separate type hierarchy (…snip…). Maybe an alternative way (admittedly more difficult) to have immutable collections without

Re: RFR: 8180352: Add Stream.toList() method

2020-11-06 Thread Alan Snyder
>> 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 > On Nov 6, 2020, at 1:14 AM, Remi Forax > wrote: > > > This question is asked at

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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-06 Thread Remi Forax
- Mail original - > De: "Simon Roberts" > À: "core-libs-dev" > Envoyé: Jeudi 5 Novembre 2020 18:40:44 > Objet: Re: RFR: 8180352: Add Stream.toList() method > At the risk of a can of worms, or at least of raising something that has >

Re: RFR: 8180352: Add Stream.toList() method

2020-11-05 Thread Stuart Marks
On Fri, 6 Nov 2020 03:01:42 GMT, Stuart Marks wrote: >> Looking at the linked issue, I see [this comment from Rémi >> Forax](https://bugs.openjdk.java.net/browse/JDK-8180352?focusedCommentId=14171626=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14171626): >> >>>

Re: RFR: 8180352: Add Stream.toList() method

2020-11-05 Thread Stuart Marks
On Wed, 4 Nov 2020 23:18:29 GMT, Paŭlo Ebermann wrote: >> Changes requested by orio...@github.com (no known OpenJDK username). > > Looking at the linked issue, I see [this comment from Rémi >

Re: RFR: 8180352: Add Stream.toList() method

2020-11-05 Thread Paul Sandoz
On Fri, 6 Nov 2020 02:50:29 GMT, Stuart Marks wrote: >> test/jdk/java/util/stream/test/org/openjdk/tests/java/util/stream/ToListOpTest.java >> line 73: >> >>> 71: } >>> 72: >>> 73: @Test(dataProvider = "withNull:StreamTestData", >>> dataProviderClass = StreamTestDataProvider.class)

Re: RFR: 8180352: Add Stream.toList() method

2020-11-05 Thread Stuart Marks
On Thu, 5 Nov 2020 19:47:43 GMT, Paul Sandoz wrote: >> 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-05 Thread Paul Sandoz
On Tue, 3 Nov 2020 01:33:32 GMT, Stuart Marks wrote: > 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-05 Thread Simon Roberts
At the risk of a can of worms, or at least of raising something that has long since been discussed and rejected... 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-05 Thread Stuart Marks
On Wed, 4 Nov 2020 23:03:02 GMT, Paŭlo Ebermann wrote: >> 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-05 Thread Stuart Marks
On Wed, 4 Nov 2020 09:46:32 GMT, Zheka Kozlov wrote: >> 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Tagir Valeev
Hello! > The min() and max() methods are not null hostile. If you pass a > null-friendly comparator (such as returned by the `nullsFirst()` and > `nullsLast()` comparator combinators), nulls are not a problem. No, it is the problem, the same as with findFirst(). Try it: Comparator nullFriendly

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Paŭlo Ebermann
On Wed, 4 Nov 2020 08:53:23 GMT, Zheka Kozlov wrote: >> 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Paŭlo Ebermann
On Tue, 3 Nov 2020 01:33:32 GMT, Stuart Marks wrote: > 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Brian Goetz
I wonder if we should not do the same with toList(), having toList() to be equivalent to collect(Collectors.toUnmodifiableList()) and toList(IntFunction>) allowing to use a null friendly List implementation like ArrayList. If you pull on this string all the way, we end up with "let's just

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread forax
- Mail original - > De: "Brian Goetz" > À: "Tagir Valeev" > Cc: "Remi Forax" , "Stuart Marks" > , "core-libs-dev" > > Envoyé: Mercredi 4 Novembre 2020 18:58:59 > Objet: Re: RFR: 8180352: Add Stream.toList() met

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Brian Goetz
As for nullity topic, I really welcome that the proposed toList() is null-tolerant but it worth mentioning that existing terminal operations like findFirst(), findAny(), min() and max() are already null-hostile. The min() and max() methods are not null hostile.  If you pass a null-friendly

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Remi Forax
- Mail original - > De: "Stuart Marks" > À: "core-libs-dev" > Envoyé: Mercredi 4 Novembre 2020 01:14:54 > Objet: Re: RFR: 8180352: Add Stream.toList() method > On Tue, 3 Nov 2020 18:53:23 GMT, Stuart Marks wrote: > >>> Should there

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Justin Dekeyser
Hello, Ah that's a super good news, thanks a lot for sharing ! I dream of this since 2 years <3 Best regards, Justin Dekeyser On Wed, Nov 4, 2020 at 10:24 AM Tagir Valeev wrote: > > Hello! > > On Wed, Nov 4, 2020 at 4:16 PM Justin Dekeyser > wrote: > > What about trying to make the Stream

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Zheka Kozlov
On Tue, 3 Nov 2020 01:33:32 GMT, Stuart Marks wrote: > 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Tagir F . Valeev
On Wed, 4 Nov 2020 08:50:49 GMT, Zheka Kozlov wrote: >> 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Tagir Valeev
Hello! On Wed, Nov 4, 2020 at 4:16 PM Justin Dekeyser wrote: > What about trying to make the Stream interface *flexible* to users, > instead of adding new functionalities that we could regret later? > Then, as the language usages and the trends evolve, we could really > see which of the "utils"

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Justin Dekeyser
Hello, I think the `collect(toList())` is interesting, as the developer really knows that the internal operation is collect-like. I say this because there would be another, much more functional approach, that would be of the form `stream.map(List::of).reduce(List.empty, List::concat)`, (if ever

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Zheka Kozlov
On Tue, 3 Nov 2020 01:33:32 GMT, Stuart Marks wrote: > 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Tagir Valeev
Hello! On Wed, Nov 4, 2020 at 2:55 AM Brian Goetz wrote: > (In fact, we would be entirely justified to change the behavior of > Collectors::toList tomorrow, to match the proposed Stream::toList; the > spec was crafted to preserve this option. We probably won't, because > there are too many

Re: RFR: 8180352: Add Stream.toList() method

2020-11-04 Thread Zheka Kozlov
On Tue, 3 Nov 2020 01:33:32 GMT, Stuart Marks wrote: > 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Stuart Marks
On Tue, 3 Nov 2020 18:53:23 GMT, Stuart Marks wrote: >> Should there be a test that tests the default implementation in >> `j.u.s.Stream`? Or maybe there is and I missed that? > > @dfuch wrote: >> Should there be a test that tests the default implementation in >> `j.u.s.Stream`? Or maybe there

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Stuart Marks
On 11/3/20 3:10 AM, Florian Weimer wrote: I'd expect a test here that if the list contains a null element, `List::copyOf` throws `NullPointerException`. The new Stream.toList() actually permits null elements (by design) so it goes through a different path than List::copyOf. The new tests'

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Remi Forax
- Mail original - > De: "Martin Desruisseaux" > À: "core-libs-dev" > Envoyé: Mardi 3 Novembre 2020 23:16:49 > Objet: Re: RFR: 8180352: Add Stream.toList() method > Hello > > Le 03/11/2020 à 21:30, fo...@univ-mlv.fr a écrit : > >> Y

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread forax
Hi Aaron, > De: "Aaron Scott-Boddendijk" > À: "Remi Forax" > Cc: "Brian Goetz" , "Stuart Marks" > , "core-libs-dev" > Envoyé: Mardi 3 Novembre 2020 21:59:37 > Objet: Re: RFR: 8180352: Add Stream.toList() method > >>

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Martin Desruisseaux
Hello Le 03/11/2020 à 21:30, fo...@univ-mlv.fr a écrit : You know that you can not change the implementation of Collectors.toList(), and you also know that if there is a method Stream.toList(), people will replace the calls to .collect(Collectors.toList()) by a call to Stream.toList() for

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Aaron Scott-Boddendijk
" > > Cc: "Stuart Marks" , "core-libs-dev" > > > > Envoyé: Mardi 3 Novembre 2020 20:54:57 > > Objet: Re: RFR: 8180352: Add Stream.toList() method > > >>> There is no value in making users remember which stream methods are > >&g

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread forax
> De: "Brian Goetz" > À: "Remi Forax" > Cc: "Stuart Marks" , "core-libs-dev" > > Envoyé: Mardi 3 Novembre 2020 20:54:57 > Objet: Re: RFR: 8180352: Add Stream.toList() method >>> There is no value in making users remember wh

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Brian Goetz
There is no value in making users remember which stream methods are null-hostile and which are null-tolerant; this is just more accidental complexity. I think that ship has sailed a long ago. Some collectors are null hostile, some are not. You can make a point that a Collector is technically

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread forax
- Mail original - > De: "Brian Goetz" > À: "Remi Forax" , "Stuart Marks" > Cc: "core-libs-dev" > Envoyé: Mardi 3 Novembre 2020 19:02:37 > Objet: Re: RFR: 8180352: Add Stream.toList() method >>> This change introduces a new

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread John Rose
I agree with Stuart and Brian that streams should be null-tolerant, including in this case. And of course I’m delighted to see an immutable container as the output to the utility method; I’m a fan of reduced-copy, race-free, bug-resistant algorithms you get from immutability. On Nov 3, 2020, at

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Stuart Marks
On Tue, 3 Nov 2020 10:06:26 GMT, Daniel Fuchs wrote: >> 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Stuart Marks
On Tue, 3 Nov 2020 11:05:21 GMT, Stephen Colebourne wrote: >> 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Stuart Marks
On Tue, 3 Nov 2020 10:58:25 GMT, Stephen Colebourne wrote: >> 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Brian Goetz
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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Remi Forax
- Mail original - > De: "Stuart Marks" > À: "core-libs-dev" > Envoyé: Mardi 3 Novembre 2020 04:18:08 > Objet: RFR: 8180352: Add Stream.toList() method > This change introduces a new terminal operation on Stream. This looks like a > convenience metho

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Florian Weimer
On Tue, 3 Nov 2020 01:33:32 GMT, Stuart Marks wrote: > 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Stephen Colebourne
On Tue, 3 Nov 2020 01:33:32 GMT, Stuart Marks wrote: > 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

Re: RFR: 8180352: Add Stream.toList() method

2020-11-03 Thread Daniel Fuchs
On Tue, 3 Nov 2020 01:33:32 GMT, Stuart Marks wrote: > 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

RFR: 8180352: Add Stream.toList() method

2020-11-02 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