RFR(s): 8152617 add missing wildcards to Optional or() and flatMap()
Stuart Marks
stuart.marks at oracle.com
Fri Oct 7 17:20:28 UTC 2016
Hi all,
Please review this small API adjustment to Optional.or and flatMap to add
wildcards. This provides a bit more flexibility to callers about the types of
functions they can provide to these methods.
The or() method is new in 9 so there is no compatibility issue.
The flatMap() method was introduced in 8, so this is a change to an existing
API. There shouldn't be a binary compatibility issue, since the method's erasure
doesn't change. I *think* it is source compatible, as anything that was accepted
by the old signature:
flatMap(Function<? super T, Optional<U>> mapper)
should also be accepted by the new signature:
flatMap(Function<? super T, ? extends Optional<? extends U>> mapper)
But there may be some subtle issues of which I'm unaware.
Bug report:
https://bugs.openjdk.java.net/browse/JDK-8152617
Webrev:
http://cr.openjdk.java.net/~smarks/reviews/8152617/webrev.0/
Thanks,
s'marks
More information about the core-libs-dev
mailing list