On Mar 19, 2013, at 9:43 PM, Rob Leland <[email protected]> wrote:

> Has the optional classes been verified to serialize/deserialize correctly? I 
> noticed it tries to use the null object pattern with the use of EMPTY private 
> instance. When I have implemented the NULL pattern I have used a private 
> subclass of the object as opposed to an instance variable to insure it 
> unmarshalls correctly with a simple override of the default desearization to 
> insure this.
> 
They are not tagged as Serializable. Optionals are intended to be transitory. A 
readResolve to re-associate with the EMPTY instance would be important if they 
were serializable.
> I also wonder why a marker interface wasn't used or something more 
> substantial at least for methods like isPresent().
> 
I am not sure what you are looking for in this question.
> Also why does the static factory initialization parameters use primatives as 
> opposed to objects?
> 
The OptionalInt etc are intended to be Optional counterparts to the boxed 
types. If you prefer Optional of the boxed types you can use the reference 
Optional.
> If objects were used then there would be the oppertunity to use a abstract 
> base class, which has the potential to move the use of isPresent() strictly  
> into the base class.
> 
> Finally, are these utilities critical to some other part JDK 8 that they were 
> pushed out now as opposed to JDK 9?
> 
They are currently planned for use by the lambda streams libraries. See 
http://openjdk.java.net/projects/lambda/ and http://jdk8.java.net/lambda/ for 
more info and an implementation.

Mike
> On Mar 19, 2013 7:18 PM, <[email protected]> wrote:
> Changeset: 2241a2d34085
> Author:    mduigou
> Date:      2013-03-19 16:05 -0700
> URL:       http://hg.openjdk.java.net/jdk8/tl/jdk/rev/2241a2d34085
> 
> 8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong
> Reviewed-by: mduigou, darcy, alanb, jjb
> Contributed-by: Brian Goetz <[email protected]>
> 
> + src/share/classes/java/util/Optional.java
> + src/share/classes/java/util/OptionalDouble.java
> + src/share/classes/java/util/OptionalInt.java
> + src/share/classes/java/util/OptionalLong.java
> + test/java/util/Optional/Basic.java
> + test/java/util/Optional/BasicDouble.java
> + test/java/util/Optional/BasicInt.java
> + test/java/util/Optional/BasicLong.java
> 

Reply via email to