At some point I imagine they will have to remove or at least isolate and disarm some ubiquitous core features (e.g. serialisation and synchronisation).
(This doesn't always work out, some bad API decisions[1] will likely haunt Java forever, some features are arguably a bit undercooked (e.g. exception handling in Stream:s), but given the constraints it's kind of remarkable how well it does work)
[1] https://stackoverflow.com/questions/21410683/boolean-getbool...
May be one day Java will just retire this concept and make all exceptions unchecked. It'll be backwards-compatible change. Make `throws` clause cause deprecation warnings and that's about it.
I personally believe that it is now within reach for Java to fix checked exceptions to be ergonomic and useful. If they do it, Java could have one of the best error handling paradigms out of any modern language, but I suspect it won't happen because the community has come to land so firmly against checked exceptions.
JSR-305, checker framework, Optional are all half-baked workarounds evidenced by the lack of their adoption.
I can’t remember the last time I encountered one by using the proper compile time checks. It does need to be enforced organization-wide, and not partially with annotations, but if you can make that change then you can code in Java without the mental overhead of null.
Or simply wrap the return with Optional.ofNullable, checkstyle will not accept it if you don’t.
When you're sufficiently careful, you can reduce accidental nulls down to the level of minor inconvenience.
But no amount of care on your part will stop your teammates from deliberately using nulls.
Even IntelliJ right now will tell you off for using an Optional field instead of a nullable one.
> then you can pretty much eliminate NPE.
NPEs is only one kind of cost incurred by the lack of null safety. The other is all the unnecessary "if (x == null) {" boilerplate code caused by the uncertainty and defensive programming, which increases complexity and worsens readability.
It's not. It's another half-feature into the collection of half-features mentioned in my post.