RFR JDK-8209553: ExceptionInInitializerError can have a default detail message if the cause is given
mandy chung
mandy.chung at oracle.com
Wed Aug 15 21:46:24 UTC 2018
ExceptionInInitializerError(Throwable cause) sets the detail message to
null. It'd be helpful to include a detail message rather than null
as in Throwable(Throwable cause) that constructs a new throwable
with a default message cause==null ? null : cause.toString().
This would help troubleshooting of writing new bootstrap methods
where VM currently asserts non-null linkage error message [1] where
there are other solutions such as constructing the message in
the VM or removing the assert.
This patch proposes to change ExceptionInInitializerError(Throwable cause)
to default the detail message to cause.toString() if cause is not null.
It's an incompatibility change; for example existing code that expects
a null message will now see a detail message. But the compatibility
risk should be low as EIIE should be fatal.
This also proposes to add new LinkageError(Throwable cause) constructor
to retrofit the exception chaining mechanism and that allows to clean up
the current ExceptionInInitializerError implementation.
Webrev:
http://cr.openjdk.java.net/~mchung/jdk12/webrevs/8209553/webrev.00
I will create a CSR.
Mandy
[1] https://bugs.openjdk.java.net/browse/JDK-8208172
More information about the core-libs-dev
mailing list