There's already support for Optional.
I mean I guess a lot of code would stop compiling, or could it be deprecated somehow.
There's already support for Optional.
I mean I guess a lot of code would stop compiling, or could it be deprecated somehow.
I don't think it's a technical impossibility, but it's more likely to be solved by a JVM-based language like Kotlin than it is to get it adopted into the Java mothership.
IIRC that proposition for value types makes them more akin to structs, without inheritance and dynamic methods. And I don't remember whether the fields are final, but given the current trend towards making everything as immutable as possible, they probably are.
Kotlin (or any other JVM variant that does non-nullability in a seamless way) and coding guidelines should get you 90% of the way to a null-free world.