[code-reflection] RFR: Transform runtime test to JUnit
Adam Sotona
asotona at openjdk.org
Fri Sep 19 10:22:22 UTC 2025
On Fri, 19 Sep 2025 09:17:37 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
> Transform runtime test to JUnit.
test/jdk/java/lang/reflect/code/bytecode/TestBytecode.java line 716:
> 714: if (receiver1 != null) argl.add(receiver1);
> 715: argl.addAll(Arrays.asList(args));
> 716: Assertions.assertEquals(d.testMethod.invoke(receiver2, args), mh.invokeWithArguments(argl));
TestNG `Assert.assertEquals(Object, Object)` does much more complex comparison than its JUnit peer.
If the arguments represents arrays, it compares them by content.
A fragment of that functionality (to satisfy types compared in this test) can be mocked in JUnit by following code:
static void assertEquals(Object expected, Object actual) {
switch (expected) {
case int[] expArr when actual instanceof int[] actArr ->
Assertions.assertArrayEquals(expArr, actArr);
case Object[] expArr when actual instanceof Object[] actArr ->
Assertions.assertArrayEquals(expArr, actArr);
case null ->
Assertions.assertEquals(expected, actual);
default ->
Assertions.assertEquals(expected, actual);
}
}
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/578#discussion_r2362449653
More information about the babylon-dev
mailing list