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

Thomas Stuefe stuefe at openjdk.org
Thu Aug 29 13:09:22 UTC 2024


On Thu, 29 Aug 2024 12:30:26 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/hotspot/share/classfile/javaClasses.hpp line 138:
>> 
>>> 136:   // Legacy variants that truncate the length if needed
>>> 137:   static int    utf8_length_as_int(oop java_string);
>>> 138:   static int    utf8_length_as_int(oop java_string, typeArrayOop string_value);
>> 
>> I don't get the point of this variant of the function. It takes a string and a typearray. What is the contract here, is the only value allowed for typearray the array oop underlying the string? If yes, why do you assert for value equality in the function? That implies I can feed in any typearrayoop here as long as it has the same value as the string.
>> 
>> I can only see a single point where this function is used, so that does not explain much. Maybe I am overlooking something, but why not just inline the code into that one using call site?
>
> The as_int versions mirror the existing not-as-int versions. I admit I don't really see the point of unwrapping the array from the string but then pass them both. I assume they are intended/required to be a matching pair.

Thanks for clarifying. 

Okay then. My approval of the patch stands.

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

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


More information about the serviceability-dev mailing list