RFR(s): 8140281 add no-arg Optional.orElseThrow() as preferred alternative to get()

Stuart Marks stuart.marks at oracle.com
Tue Dec 12 01:08:13 UTC 2017


On 12/9/17 1:20 AM, Stephen Colebourne wrote:
> On 8 December 2017 at 00:33, Stuart Marks <stuart.marks at oracle.com> wrote:
>> Please review this changeset that introduces a new no-arg method
>> orElseThrow() to Optional, as a preferred alternative to the get() method.
> 
> I am willing to accept this addition as it has an obvious parallel to
> the existing supplier method.
> 
> My position on removing get() has not changed however, and as such I
> am displeased with the addition of the "preferred alternative" text.

Hi Stephen,

Thanks for your comments on this issue.

I know that you like get() (or at least you're OK with it). But even three years 
after the release of Java 8, I still see bad code written with get(), so I don't 
think this problem is going to go away.

Also, I should clarify that it was never the intent to remove get(), just to 
deprecate it not-for-removal. However, I realize that even deprecation has a 
cost, which is why I'm not pursuing it as part of this proposal.

s'marks


More information about the core-libs-dev mailing list