RFR: 8048190: NoClassDefFoundError omits original ExceptionInInitializerError [v5]
David Holmes
dholmes at openjdk.java.net
Mon Aug 9 23:44:33 UTC 2021
On Mon, 9 Aug 2021 23:21:40 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> src/hotspot/share/classfile/javaClasses.cpp line 2685:
>>
>>> 2683: assert(stack_trace->is_objArray(), "Should be an array");
>>> 2684:
>>> 2685: // If the original exception was in the bootstrap class loader, then use that
>>
>> Not sure that is a sufficiently strong enough check due to -Xbootclasspath:/a. You may need to check actual java.base module.
>
> I don't know. The worry was that the exception would be unloaded, which it won't if it's in the bootstrap class loader.
There are multiple problems with instantiating an unknown instance of an exception type. The unloading aspect is only one of those problems. To be safe you really only want to instantiate a well-defined set of well-behaved exceptions types - and that would be those (or a subset thereof) in the base module.
Maybe the safest thing is to always create an instance of EIIE to hold the original stacktrace and message. I actually find it semantically more appealing to have the NCDFE be caused by an EIIE.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4996
More information about the hotspot-dev
mailing list