RFR: 8325945: Error reporting should limit the number of String characters printed [v2]

Thomas Stuefe stuefe at openjdk.org
Wed Jul 17 06:28:52 UTC 2024


On Wed, 17 Jul 2024 05:38:41 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/hotspot/share/classfile/javaClasses.cpp line 785:
>> 
>>> 783:       index = length - (max_length / 2);
>>> 784:       abridge = false; // only do this once
>>> 785:     }
>> 
>> Instead of the trailing "abridged", in similar cases I printed out the number of omitted characters. E.g.
>> 
>> "Very long long long ... (53 characters omitted) ... long long string"
>> 
>> Makes it obvious how much has been cut, and no danger of confusing the ellipse with naturally occurring dots.
>> 
>> Additionally, I would only do this if length > max_length + X, with X being at least as long as the middle part (3 characters if you only print an ellipse). You end up with printed strings that may be slightly longer than maxlen, but OTOH the output is clearer. Otherwise you may indicate omission where none happened (if length == max_length)
>
> @tstuefe  - thanks for looking at this Thomas. I don't get your second point. First I only abridge when length > max_length. Second adding in the X fudge factor just means max_length should have been set differently.
> 
> To your first point, there will be similar changes to this coming so it would be good to standardise on how to report them. I like the idea you propose, but I couldn't find the code you mention. ??

Hi David,

> I don't get your second point. First I only abridge when length > max_length. Second adding in the X fudge factor just means max_length should have been set differently.

AFAICS you start abridging if length is exactly max_length. So, you could have:

"Hallo David" maxlen=11 => "Hallo ... omitted 0 characters ... David" 

which is just strange. Additionally, it may seem just strange to replace a small inner portion with a larger "omitted" text, because then the text plus replacement is larger than the original text, e.g. 

"Hallo David" maxlen=10 => "Hallo ... omitted 1 characters ... David" 

So my proposal would be to have a stretch zone the size of the omission text (roughly, modulo variable digits in text) and allow larger text than maxlen but smaller than the stretch zone length. E.g.

"Hallo David" maxlen=10 => "Hallo David"
"Hallo 0123456789012345678901234567890123456789 David" => "Hallo 01234 ... omitted 30 characters ... 56789 David"

Its mainly for optics.

> To your first point, there will be similar changes to this coming so it would be good to standardise on how to report them. I like the idea you propose, but I couldn't find the code you mention. ??

Oh, sorry, this was not in the OpenJDK; this was for a different product I worked on at SAP. But that omission text form served us well.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20150#discussion_r1680478197


More information about the hotspot-dev mailing list