RFR 8050819: Please add java.util.Stream.ofNullable(T object)

Remi Forax forax at univ-mlv.fr
Mon Jan 26 22:15:09 UTC 2015

On 01/26/2015 07:42 PM, Alan Bateman wrote:
> On 26/01/2015 18:32, Paul Sandoz wrote:
>> On Jan 20, 2015, at 7:05 PM, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
>>> Hi,
>>> http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8050819-Stream-ofNullable/webrev/ 
>>> Stream.ofNullable can make it easier to work fluently when streams 
>>> are produced, for example within flatMap.
>> So far there have been "null" reviews :-)
> This looks okay to me, and the naming consistent with Optional.
> -Alan.

I'm not sure this method pull it's own weight,
it can be written like this:

I'm pretty sure that the JIT will remove the creation of the 
intermediary Optional
and adding a method in the JDK that considers that null is an acceptable 
value is in my opinion the wrong signal to send.


More information about the core-libs-dev mailing list