On Mon, 28 Jul 2025 14:04:32 GMT, Shaojin Wen <s...@openjdk.org> wrote:

>> I agree that we can expect arrays to be laid out as a contiguous chunk of 
>> memory with the intuitively expected element size.
>> _But..._ AFAIK this is not specified anywhere in the JVMS, although it is 
>> true that it is tacitly assumed in many low-level parts of the codebase. So, 
>> in this sense, I'm fine with your code.
>
> There are many places in the String class that use `<< 1` and `>> 1` to 
> handle the length of UTF16 byte[], so is it okay to use `<< 1` directly in 
> the current version of the code?

For consistency, I prefer the explicit constant shift `<< 1` and `>> 1`.
Using the String.UTF16 symbol makes the code more verbose.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24773#discussion_r2237112304

Reply via email to