Hi Mandy,
Not a review - sorry :)
On 16/08/2018 7:46 AM, mandy chung wrote:
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.
I think that's just a bug in the VM code making inappropriate
assumptions! There shouldn't have to be a detail message, especially in
a wrapping exception like ExceptionInInitializerError! It only gets
thrown because some other exception was thrown, there's really no more
detail for the EIIE itself. Promoting the cause's detail message to be
the detail message of the EIIE just seems wrong to me.
Did this come about through the new code that saves the original cause
of the EIIE so that it can be reported when the subsequent
NoClassDefFoundError is thrown due to the class being in the erroneous
state? (I don't recall if that actually got pushed.)
David
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