On Apr 9, 2020, at 1:58 PM, Remi Forax <fo...@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.

— John

Reply via email to