RFR: 8343962: [REDO] Move getChars to DecimalDigits [v7]

Raffaello Giulietti rgiulietti at openjdk.org
Fri Jan 17 16:08:41 UTC 2025


On Fri, 17 Jan 2025 15:46:25 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   fix comment, from @rgiulietti
>
> src/java.base/share/classes/jdk/internal/util/DecimalDigits.java line 434:
> 
>> 432: 
>> 433:     private static void putCharUTF16(byte[] buf, int charPos, int c) {
>> 434:         UNSAFE.putChar(buf, ARRAY_BYTE_BASE_OFFSET + ((long) charPos << 1), (char) c);
> 
> I'm not sure we can put a `char` into a `byte[]`.
> @cl4es is this safe on all platforms?

The doc of `Unsafe::putChar()` delegates to the doc of `Unsafe::putInt()` which clearly states that the `Object` and `offset` arguments must locate a variable of the same type as the one of argument `x`, which is not the case here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22023#discussion_r1920409624


More information about the core-libs-dev mailing list