[foreign-memaccess+abi] RFR: 8301261: Add linker option for specifying uncaught exception handler

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Feb 3 16:25:21 UTC 2023


On Fri, 3 Feb 2023 16:12:18 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java line 185:
>> 
>>> 183:             // where the caller is an upcall stub.
>>> 184:             Thread.UncaughtExceptionHandler uncaughtExceptionHandler = callingSequence.uncaughtExceptionHandler();
>>> 185:             MethodHandles.Lookup defineClassLookup = uncaughtExceptionHandler != null
>> 
>> Perhaps we could make this more regular by having an handler in all cases? E.g. the default handler could rethrow?
>
> The default handler would be the one installed on the thread when we encounter an exception. I don't think we can return that one here though, since someone might link the upcall stub, and then afterwards set the thread's default exception handler.
> 
> The handler specified as a linker option can be used to override that handler on a per upcall stub basis, if wanted. This is needed also in cases where native code spawns a new thread, and perhaps a user doesn't have an opportunity to set the default exception handler for that thread (before an exception is thrown).

I see - the "fallback handler" is a dynamic property (depends on the thread in which we're executing the catch block". Then I agree the code, as is now, makes sense.

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

PR: https://git.openjdk.org/panama-foreign/pull/777


More information about the panama-dev mailing list