On Tue, 22 Apr 2025 23:09:15 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> hmmm...  This pattern was copied from some other test.  We have 32 more 
>> instances of this pattern elsewhere.
>> 
>> I suspect it is not avoid declaring a checked exception.
>> What would you suggest?  Forward the `throwable` to 
>> `Thread.currentThread().getThreadGroup().uncaughtException(thread, 
>> throwable);` unconditionally?
>
> That's interesting that other tests do this. When re-throwing an exception 
> you often need to special case checked exceptions (to wrap them so that the 
> caller doesn't need to explicitly declare it), but the 
> UncaughtExceptionHandler can handle both, so I don't know why it was done 
> that way.
> 
> You might try just unconditionally forwarding all throwables, but not sure.

Turns out, this is required by junit framework to properly handle the failed 
tests.

If we pass all the Throwables to the thread group, then a RuntimeException 
thrown from a `@Test` does not mark the unit test as failed, though the 
stacktrace does appear in `stderr`;  a thrown `Error` will mark the test as 
failed.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1677#discussion_r2056736082

Reply via email to