RFR: 8048190: NoClassDefFoundError omits original ExceptionInInitializerError [v2]
David Holmes
dholmes at openjdk.java.net
Fri Aug 6 04:15:29 UTC 2021
On Thu, 5 Aug 2021 17:39:59 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> I wonder if I can use a predefined exception like ExceptionInInitializerError and put the original exception in with the message?
>
> You're right. new_exception does surprising things. If it gets an exception during the call, it returns a handle to that exception, which is not what I want at all. I'll return null in that case.
I have to wonder whether `new_exceptions`'s behaviour is what anyone would want! It could lead to some very strange exceptions being thrown - see for example `ConstantPool::throw_resolution_error` where it can throw a resolution error with the wrong cause!
It may be okay to restrict re-creation of the exception to types in java.base as their construction seems benign with no context dependency and they should always have the necessary constructor.
Using ExceptionInInitializerError as the cause of the NCDFE may be okay for other cases.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4996
More information about the hotspot-dev
mailing list