RFR: 8376277: Migrate java/lang/reflect tests away from TestNG
Alan Bateman
alanb at openjdk.org
Mon Jan 26 08:40:04 UTC 2026
On Mon, 26 Jan 2026 05:19:25 GMT, Chen Liang <liach at openjdk.org> wrote:
> Mostly routine conversions. Manual updates are mostly assertThrows migration, assertArrayEquals fixes, and removal of TestInstance to convert method sources to be static.
>
> 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.
test/jdk/java/lang/reflect/ChainedReflection.java line 42:
> 40: class Inner {
> 41: // JUnit does not allow test class to declare multiple constructors
> 42: Inner() throws ReflectiveOperationException {
This comment might be confusing to future maintainers, may not immediately seeing the compiler generated constructor. Maybe expand the comment on this and put it on the class rather the constructor.
test/jdk/java/lang/reflect/IllegalArgumentsTest.java line 28:
> 26: * @bug 8277964
> 27: * @summary Test IllegalArgumentException be thrown when an argument is invalid
> 28: * @run junit/othervm/timeout=720 IllegalArgumentsTest
On the surface, the test is begging to use assertThrows but this a test for a C2 issue so I agree it shouldn't be changed.
test/jdk/java/lang/reflect/Proxy/DefaultMethods.java line 239:
> 237: Method m = I12.class.getMethod("concat", Object.class, Object[].class);
> 238: assertTrue(m.isDefault());
> 239: assertArrayEquals(new Object[] {100, "foo", true, "bar"}, (Object[]) InvocationHandler.invokeDefault(i12, m, 100, new Object[] {"foo", true, "bar"}));
It might be better to put the actuals on new line to make it easier to see expecteds vs. actuals and to avoid the horizontal scroll.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29405#discussion_r2726740168
PR Review Comment: https://git.openjdk.org/jdk/pull/29405#discussion_r2726717219
PR Review Comment: https://git.openjdk.org/jdk/pull/29405#discussion_r2726712044
More information about the core-libs-dev
mailing list