Ah. I see.
Well, while I see the benefit you're trying to achieve, I doubt you'll
ever see that. In Java, maybe it's less clear, but in C# a significant
feature of a reference type is that it's nullable. In other words, it's
not just a side-effect of being a reference type, it's a fundamental
characteristic of the type.
Same in java, i think. The crux of my argument is that in the vast
majority of cases, nullability is actually not helpful. Pick any class,
from any library, and look at the parameters to its methods: in how many
cases is it legitimate for them to be null? The chances are it's few or
none. Of course, we need nullable variables and parameters in some cases,
but most of the time, preventing nullness makes our programs more
reliable.
Besides, at this point retrofitting Java or C# to enforce a
"non-nullable" attribute on the type would be completely impractical.
You'd have to go through the entire framework and either get rid of or
wrap in exceptions somehow all of the places where a null value is
possible.
Oh, absolutely. It would be a complete nightmare to retrofit, and we'll
never have it in java.
Maybe you'll get it in the next language.
Here's hoping!
tom