RFR: 8229186: Improve error messages for TestStringIntrinsics failures [v9]

Igor Ignatyev iignatyev at openjdk.java.net
Thu Oct 8 20:48:38 UTC 2020


On Sat, 3 Oct 2020 19:15:00 GMT, Evgeny Nikitin <enikitin at openjdk.org> wrote:

>> pre-Skara RFR thread: [link](https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2020-May/038416.html)
>> 
>> Error reporting was improved by writing a C-style escaped string representations for the variables passed to the
>> methods being tested. For array comparisons, a dedicated diff-formatter was implemented.
>> Sample output for comparing byte arrays (with artificial failure):
>>  ----------System.err:(21/1553)----------
>>  Result: (false) of 'arrayEqualsB' is not equal to expected (true)
>>  Arrays differ starting from [index: 7]:
>>  ... 5, 6,   7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
>>  ... 5, 6, 125, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
>>            ^^^^
>>  java.lang.RuntimeException: Result: (false) of 'arrayEqualsB' is not
>>  equal to expected (true)
>>           at
>>  compiler.intrinsics.string.TestStringIntrinsics.invokeAndCheckArrays(TestStringIntrinsics.java:273)
>>            at ... stack trace continues - E.N.
>>  Sample output for comparing char arrays:
>>  ----------System.err:(21/1579)*----------
>>  Result: (false) of 'arrayEqualsC' is not equal to expected (true)
>>  Arrays differ starting from [index: 7]:
>>  ... \\u0005, \\u0006, \\u0007, \\u0008, \\u0009, \\n, ...
>>  ... \\u0005, \\u0006,      }, \\u0008, \\u0009, \\n, ...
>>                      ^^^^^^^
>>  java.lang.RuntimeException: Result: (false) of 'arrayEqualsC' is not
>>  equal to expected (true)
>>           at
>>  compiler.intrinsics.string.TestStringIntrinsics.invokeAndCheckArrays(TestStringIntrinsics.java:280)
>>            at
>>  ... and so on - E.N.
>> 
>> testing: open/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java on linux, windows, macosx.
>
> Evgeny Nikitin has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add null values support and two-way testing

Changes requested by iignatyev (Reviewer).

test/lib/jdk/test/lib/format/ArrayDiff.java line 117:

> 115:         if (second == null) {
> 116:             throw new IllegalArgumentException("Second array argument for ArrayDiff is null");
> 117:         }

it's more common (and less surprising) to throw NPE in such cases, preferably by using `Objects::requireNonNull`

test/lib/jdk/test/lib/format/Diff.java line 37:

> 35:      * Default limits for formatters
> 36:      */
> 37:     public static class Defaults {

I'd add a no-op private no-arg ctor to show that this class isn't expected to be instantiated.

test/lib/jdk/test/lib/format/ArrayCodec.java line 325:

> 323:         }
> 324:
> 325:         return 0;

shouldn't it be -1?

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

PR: https://git.openjdk.java.net/jdk/pull/112


More information about the core-libs-dev mailing list