RFR(L): 8218628: Add detailed message to NullPointerException describing what is null.

Lindenmaier, Goetz goetz.lindenmaier at sap.com
Fri Mar 29 07:49:40 UTC 2019

Hi Mandy,

The JBS is offline, so I'll just reply on this item for now:

> > > Since the JEP quotes that NullPointerExceptions are thrown frequently
> > > and swallowed, it would help if you can generate some numbers.
> > > This JEP will help the discussion on the proposed feature and design and avoid
> > > any confusion/assumption of the implementation.
> > I'll generate some numbers.  Is running jvm2008 fine?
> A benchmark may not be a good representative.  I'd be interested in a real application
> to support the claim.  

I ran the following applications:
  Jbb2005: 15 NPE raised
  Jvm2008: 5 NPE raised, only in 'check' benchmark
  SAP application: 16138 NPE raised.
None of these called NPE.getMessage().

This SAP application is known to us for bad NPE behavior ��
and runs a few hours. It's from our GC stress tests.
I think 16000 is still a small number given the runtime of
the test.

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."

Best regards,

More information about the core-libs-dev mailing list