RFR: 7903526: jtreg should handle all exceptions

Jaikiran Pai jpai at openjdk.org
Tue Oct 31 06:37:00 UTC 2023


On Tue, 10 Oct 2023 20:49:42 GMT, Leonid Mesnik <lmesnik at openjdk.org> wrote:

> Currently, jtreg executes a test in MainThreadGroup and checks uncaught exceptions for this group. So it handles all exceptions if the test doesn't create new thread groups.
> However, the virtual threads don't belong to MainThreadGroup and jtreg silently ignores all exceptions thrown by virtual threads.
> 
> The testing shows that we have already some problems in jdk/jdk and probably in UR releases. There are 13 test failures in tier1 and several tens in the execution of tests that use secutiry-manager and run with a virtual thread.
> 
> It wonder if it makes sense to have this check conditional using some java property and start fixing tests after jtreg is release and smoothly switch execution to the new version.

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.

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

PR Review Comment: https://git.openjdk.org/jtreg/pull/172#discussion_r1377110689


More information about the jtreg-dev mailing list