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

Evgeny Nikitin enikitin at openjdk.java.net
Wed Sep 30 14:30:29 UTC 2020


On Mon, 28 Sep 2020 20:00:35 GMT, Igor Ignatyev <iignatyev at openjdk.org> wrote:

>> Evgeny Nikitin has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Replace new space string with constant
>
> Changes requested by iignatyev (Reviewer).

> 1. granted you can't change `invokeAndCheck`'s 2nd argument to bool as there are other values being passed, but you can
> change  `invokeAndCompareArrays` to accept an `Object` and compare expected and actual values by `Object::equals`.

Well, I think that would make `invokeAndCompareArrays` look less specific and confuse a reader by creating a false
impression that it could be called with an Object as an expected result. In reality, the method is only called with
'equals' of different signatures, and 'equals' does always return boolean. It could've been named
'invokeEqualsOnArraysAndCompareThem` :)

The other method, `invokeAndCheck` is different. It can call, for example, `String.concat("abc", "def")` and expect the
String "abcdef" as result. It does really need to be generic.

> 2. even if you can't change output of these two methods to be the same (which I so far failed to see why), you still
> can change `invokeAndCheck`'s `message` var to include actual and expected values in the same way as
> `invokeAndCompareArrays` does.

`invokeAndCompareArrays` / `ArrayDiff` compares two huge arrays and present a nice short *slice* in the difference
area. The short slice is possible because we do  a limited task - compare arrays.
 `invokeAndCheck` , on the other hand, can have as parameters the `utf16`, a string of 10K symbols. Do we really need a
 10K string as output in our log?

> you don't need `ArrayCodec::of(Object array)` anymore, do you?

Unfortunately, it is used in the ArrayCodec.format (which is used in TestStringIntrinsics.java) - to make it possible
to call it with everything and not swamp the code with overloads.

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

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


More information about the core-libs-dev mailing list