hg: jdk8/tl/jdk: 8001642: Add Optional<T>, OptionalDouble, OptionalInt, OptionalLong

Rob Leland the.rob.leland at gmail.com
Wed Mar 20 04:43:25 UTC 2013

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.

I also wonder why a marker interface wasn't used or something more
substantial at least for methods like isPresent(). Also why does the static
factory initialization parameters use primatives as opposed to objects? 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?
On Mar 19, 2013 7:18 PM, <mike.duigou at oracle.com> 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 <brian.goetz at oracle.com>
> + 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

More information about the core-libs-dev mailing list