null checks vs. class resolution, and translation strategy for casts
john.r.rose at oracle.com
Thu Apr 9 21:07:10 UTC 2020
On Apr 9, 2020, at 1:58 PM, Remi Forax <forax at univ-mlv.fr> wrote:
> I don't fully understand why not using checkcast because from the user POV the message will be better than just NPE.
When today I try unbox an Integer but encounter a null,
my experience is “NPE” rather than a more informative
“failed to unbox this int because you handed me a null”.
I agree, generally speaking, that messages should be more
informative. But surely the bar is low here, and “NPE” is
not out of bounds?
That said, an indy-based solution has full information
about the use site, and can be coaxed to generate whatever
user experience we desire. And so would intrinsic based
solutions, of which I am favorable to some but not all.
Perhaps we want another (intrinsically optimized) version
of Objects::requireNonNull, which takes a second argument
that assists in generating a better diagnostic.
More information about the valhalla-spec-observers