RFR (L, final): 8218626: Add detailed message to NullPointerException describing what is null.
mark.reinhold at oracle.com
mark.reinhold at oracle.com
Tue Oct 1 22:28:33 UTC 2019
2019/9/24 1:13:14 -0700, goetz.lindenmaier at sap.com:
> http://cr.openjdk.java.net/~goetz/wr19/8218628-exMsg-NPE/19/
This is very nice work! I especially appreciate the thorough tests.
Looking at the tests, and the details of the JEP, I noticed that the
generated messages all end in a period (e.g., “... is null.”). This
is pretty unusual in the JDK and jarring to the eye, except in the
rare cases in which an exception message is composed of multiple
distinct sentences. I’m surprised that no one noticed this before.
As a data point, of the 17,999 messages that I was able to find in
invocations of exception constructors in the JDK 14 library code just
now, only 998 of them end in periods. (I didn’t look at HotSpot, which
is trickier to grep for such things.)
So, I suggest you drop the trailing periods.
I also noticed that the generated messages use single quotes (‘'’) to
quote the names of fields, etc., rather than double quotes (‘"’).
On this choice, our corpus is less instructive: Of the 17,999 messages
I gathered, 446 of them use quotes of some sort, 227 of those use double
quotes, and 219 use single quotes.
Even so, I’ll propose here that double quotes are preferable: They’re
consistent with the Java language itself, they’re consistent with common
usage in both American and British English, and they’re less apt to be
confused with single quotes used as apostrophes (e.g., "MemoryHandler
can't load handler target \"" + targetName + "\"").
So, I also suggest that you change the single quotes to double quotes.
Fortunately, and because you have such good tests, this is pretty easy
to do. Attached is a patch against your patch that makes these changes,
and after which all the tests still pass.
- Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: npe-periods-quotes.patch
Type: text/x-diff
Size: 58848 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20191001/73382aae/npe-periods-quotes-0001.patch>
More information about the core-libs-dev
mailing list