RFR(M): 8203824: Chain exception from initialization in later NoClassDefFoundErrors.
goetz.lindenmaier at sap.com
Fri Jun 1 16:02:03 UTC 2018
If static initialization of a class fails, an ExceptionInInitializerError
is thrown. Later accesses to this class will fail, too. They report
a NoClassDefFoundError. This is misleading, as the class has been
found in first place but the initialization failed.
To give more context, retain the previous ExceptionInInitializerError
and chain it into the NoClassDefFoundError:
I added a field to java/lang/Class to retain the exception.
This is the design we followed in SAP JVM. I am not sure whether
the additional memory consumption of Class is acceptable, or whether
a hash map holding the exceptions internally would be a better
I also left out code that transforms the Throwable::backtrace in the retained
ExceptionInInitializerError and it's recursively chained exceptions into
Throwable::stackTrace and limits the recursively chained exceptions.
If this change is appreciated, I'll add that in a later change.
I found a test for NoClassDefFoundError messages and extended that.
I moved the existing test into the canonical location under /exceptionMsgs/
Failing class initialization throws a ExceptionInInitializerError.
Later accesses to this class throw a NoClassDefFoundErrors
hiding the original cause.
This change adds code to chain the initial EIIE in the NCDFE.
The initial EIIE is stored in the Class that failed to initialize.
More information about the hotspot-runtime-dev