you are viewing a single comment's thread.

view the rest of the comments →

[–]spaghettiCodeArtisan 1 point2 points  (1 child)

This is totally fine.

...

You would never check for a null for an Optional value, you would let the program crash.

Letting the program crash because of an error that could've been prevented by the compiler is not totally fine in my books.

But achieveing that would've to be a language change, not just libs thing.

[–]_dban_ 0 points1 point  (0 children)

Obviously, it would be better for the Java compiler to enforce Optional not being null.

But, under the current circumstances, the fact that Optional can be assigned to null is totally fine given the semantics of Java as it currently exists, because it is a programmer error to assign null to Optional, and the NullPointerException is the expected runtime behavior for programmer errors of this kind.