On Thu, 28 Aug 2025 02:13:52 GMT, Jason Mehrens <[email protected]> wrote:
>> Guanqiang Han has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Update Class.java
>>
>> Use ModifiedUtf.utfLen instead of static import for readability
>
> src/java.base/share/classes/java/lang/Class.java line 4163:
>
>> 4161: // Quick approximation: each char can be at most 3 bytes in
>> Modified UTF-8.
>> 4162: // If the string is short enough, it definitely fits.
>> 4163: if (name.length() * 3 <= JAVA_CLASSNAME_MAX_LEN) {
>
> Won't this incorrectly return true on overflow?
Yeah, it’s better to check if `name.length() <= JAVA_CLASSNAME_MAX_LEN / 3`,
probably faster too as the latter constant folds the value of
`JAVA_CLASSNAME_MAX_LEN / 3`.
Suggestion:
if (name.length() <= JAVA_CLASSNAME_MAX_LEN / 3) {
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26802#discussion_r2306046574