RFR: 8340493: Fix some Asserts failure messages

Weijun Wang weijun at openjdk.org
Tue Dec 17 14:35:38 UTC 2024


On Tue, 17 Dec 2024 12:57:43 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

>> test/lib/jdk/test/lib/Asserts.java line 448:
>> 
>>> 446:         if ((lhs == rhs) || (lhs != null && lhs.equals(rhs))) {
>>> 447:             msg = Objects.toString(msg, "assertNotEquals")
>>> 448:                     + ": expected not equals but was " + Objects.toString(lhs);
>> 
>> Same comment as above `assertNotEqualsByteArray(byte[] lhs, byte[] rhs, String msg)`
>
> This might hide problems with the implementation of `equals`

But this would be very uncommon and once it happens the developer would find out the problem, right?

Maybe I can use `Objects.toString(rhs)` in the message. `lhs` (as the expected value) is more likely to be a constant.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21101#discussion_r1888624756


More information about the core-libs-dev mailing list