[lworld] RFR: 8361496: [lworld] Treating interfaces as isValue() leads to failed assert [v2]

Chen Liang liach at openjdk.org
Tue Jul 15 22:32:03 UTC 2025


On Tue, 15 Jul 2025 14:52:43 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Junit composes the exception message with the expected, actual values and the string provided, also there is the line number.
>
> True, but seeing true and false by themselves doesn't communicate anything about the failure and you have to go look at the source and the line number and decode what assertEquals is comparing.
> It may not be worth much effort but the message could be more informative.

I think the exception message is acceptable: I tweaked `isValueObjectCompatible` to erroneousely return `true` for `Integer[].class`, and this is the message:


STARTED    ValueClassTest::testIsValueObjectCompatible 'testIsValueObjectCompatible()'
org.opentest4j.AssertionFailedError: array class ==> expected: <false> but was: <true>
        at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
        at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
        at org.junit.jupiter.api.AssertFalse.failNotFalse(AssertFalse.java:63)
        at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:36)
        at org.junit.jupiter.api.Assertions.assertFalse(Assertions.java:239)
        at ValueClassTest.testIsValueObjectCompatible(ValueClassTest.java:56)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
FAILED     ValueClassTest::testIsValueObjectCompatible 'testIsValueObjectCompatible()' [16ms]

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1504#discussion_r2208832755


More information about the valhalla-dev mailing list