RFR: 8048190: NoClassDefFoundError omits original ExceptionInInitializerError [v2]

Coleen Phillimore coleenp at openjdk.java.net
Fri Aug 6 13:50:30 UTC 2021


On Fri, 6 Aug 2021 04:12:21 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> 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.

Thanks David.  I filed an RFE for someone to look at this (maybe me) and write some tests.

I've reworked this patch a bit and will write a test for this case.  I create the new exception when I save it, which seems like a better time to do it, so I only need OopHandle in the table. This is closer to my first prototype now.  Also, if the exception's class loader isn't NULL, I'll do a switcheroo to ExceptionInInitializerError and add the name to the exception message.  Hopefully this makes this feature useful most of the time.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4996


More information about the hotspot-dev mailing list