RFR: 7903526: jtreg should handle all exceptions [v2]
Leonid Mesnik
lmesnik at openjdk.org
Tue Oct 31 20:47:04 UTC 2023
On Tue, 31 Oct 2023 06:38:14 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> src/share/classes/com/sun/javatest/regtest/agent/MainWrapper.java line 76:
>>
>>> 74: MainThreadGroup tg = new MainThreadGroup();
>>> 75:
>>> 76: Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
>>
>> I think if we do decide to set a JVM level default uncaught exception handler then it has to be done only for the case where the `Thread` instance returned by the test thread factory (if there is one) is a virtual thread. So something like:
>>
>>
>> if (t.isVirtual()) {
>> Thread.setDefaultUncaughtExceptionHandler(.....)
>> }
>>
>> That way we don't interfere with uncaught exception handlers when platform thread is being used.
>
> Finally, the major issue with setting a JVM level uncaught exception handler is that, tests will no longer be able to expect the `Thread.getDefaultUncaughtExceptionHandler()` to ever be `null`, even if they launch in `/othervm` mode. I think that's a problem. I can't recollect if jtreg testing framework has other similar cases where it interferes with the tests even with the usage of `/othervm`.
No, the plan is to catch all unhandled exceptions. The virtual threads are only a particular case but might be the most common. However, I think we shouldn't silently ignore any of the unhandled exceptions. Some exceptions are already handled using ThreadGroup, and the fix doesn't break this, just add more handling.
-------------
PR Review Comment: https://git.openjdk.org/jtreg/pull/172#discussion_r1378108569
More information about the jtreg-dev
mailing list