RFR: 8338257: UTF8 lengths should be size_t not int [v2]

David Holmes dholmes at openjdk.org
Tue Aug 20 03:56:51 UTC 2024


On Tue, 20 Aug 2024 03:16:29 GMT, Dean Long <dlong at openjdk.org> wrote:

>> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add missing cast for signed-to-unsigned converion.
>
> src/hotspot/share/classfile/javaClasses.cpp line 695:
> 
>> 693:   // `length` is used as the incoming number of characters to
>> 694:   // convert, and then set as the number of bytes in the UTF8 sequence.
>> 695:   size_t  length = java_lang_String::length(java_string, value);
> 
> Above comment looks wrong.  `length` is not an in/out reference below, so why not leave it as `int` at line 695?  Assigning `int` to `size_t` will introduce a -Wsign-conversion warning.

Thanks for looking at this @dean-long ! Good catch. Two places in the `String` code had leftovers from an earlier incarnation of the fix.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20560#discussion_r1722651664


More information about the serviceability-dev mailing list