RFR: 8376277: Migrate java/lang/reflect tests away from TestNG
Eirik Bjørsnøs
eirbjo at openjdk.org
Mon Jan 26 06:41:52 UTC 2026
On Mon, 26 Jan 2026 05:19:25 GMT, Chen Liang <liach at openjdk.org> 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
More information about the core-libs-dev
mailing list