RFR(L): 8218628: Add detailed message to NullPointerException describing what is null.
Lindenmaier, Goetz
goetz.lindenmaier at sap.com
Mon Apr 1 07:12:06 UTC 2019
Hi Peter,
> -----Original Message-----
> From: Peter Levart <peter.levart at gmail.com>
> Sent: Freitag, 29. März 2019 16:44
> To: Lindenmaier, Goetz <goetz.lindenmaier at sap.com>; 'Mandy Chung'
> <mandy.chung at oracle.com>
> Cc: core-libs-dev at openjdk.java.net; maurizio.cimadamore at oracle.com;
> hotspot-runtime-dev at openjdk.java.net
> Subject: Re: RFR(L): 8218628: Add detailed message to NullPointerException
> describing what is null.
>
>
>
> On 3/29/19 4:36 PM, Peter Levart wrote:
> >
> >
> > On 3/29/19 8:49 AM, Lindenmaier, Goetz wrote:
> >> So I want to withdraw my claim that NPEs are thrown frequently.
> >> Probably I was biased by my compiler construction background,
> >> remembering NPE checks are all over the place in the code.
> >>
> >> But I think I can still keep the claim that the message is
> >> printed rarely.
> >>
> >> I'll adapt the JEP saying something like this:
> >> "While exceptions are supposed to be thrown rarely, i.e., only
> >> In exceptional situations, most are swallowed without ever
> >> looking at the message. Thus, overhead in getMessage() will
> >> not fall into account."
> >
> > Is this really a realistic assumption? That NPE exceptions are mostly
> > swallowed in most programs despite the fact that swallowing exceptions
> > (and throwing them to control the flow) is an anti-pattern? Is
> > majority of code really so badly written? I would expect that most
> > programs contain an exception handler of some kind that at least logs
> > all unexpected exceptions.
> >
> > I think JDK should assume that NPEs are not frequent in most well
> > written programs. Because in well written programs all unexpected
> > exceptions are at least logged somewhere and this alone guarantees
> > that programs are eventually "fixed" to not throw them frequently...
> >
> > Regards, Peter
>
> So I would say that there are two kinds of programs (which kind is in
> majority doesn't matter):
>
> a - programs that throw and catch exceptions for exceptional situations
> only (i.e. non frequently) - they also print the exceptions' messages
> b - programs that throw and swallow exceptions frequently, but they
> mostly don't print their messages
>
> In either case .getMessage() is not called frequently for kind (a) and
> hopefully also for kind (b).
>
> Regards, Peter
Hi,
I agree with this, and my numbers show
that the message is not printed frequently in any case.
Best regards,
Goetz.
More information about the core-libs-dev
mailing list