On Mon, 26 Jan 2026 05:19:25 GMT, Chen Liang <[email protected]> wrote:

> Notably, I avoided assertThrows migration in `ChainedReflection` and 
> `IllegalArgumentsTest` because they seem to be very sensitive to low-level 
> reflection and runtime stuff that I fear using test framework may 
> accidentally harm.

Hmm.. I do understand your caution here. But you're already using a test 
framework, right?

If you look into the implementation of `Asssertions.assertThrows`, the only 
reflection happening is the call to `Class.isInstance` to check the expected 
exception type. 

If you want to avoid reflection entirely, there's always `assertThrowsExactly` 
which avoids reflection and contains no more exciting/exotic code than the 
tests themselves..?

The net win for code readability with `assertThrows` is very nice, it's a pity 
not to be able to use it here as well.

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

PR Comment: https://git.openjdk.org/jdk/pull/29405#issuecomment-3798099060

Reply via email to