RFR: 8347009: Speed ​​up parseInt and parseLong [v15]

Raffaello Giulietti rgiulietti at openjdk.org
Wed Feb 5 13:31:14 UTC 2025


On Wed, 5 Feb 2025 12:17:42 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 JdbExprTest
>
> src/java.base/share/classes/jdk/internal/util/DecimalDigits.java line 175:
> 
>> 173:          */
>> 174:         int d;
>> 175:         short x = UNSAFE.getShortUnaligned(str, Unsafe.ARRAY_BYTE_BASE_OFFSET + offset, false);
> 
> @wenshao I'm a bit worried about the use of Unsafe here.
> 
> This method is `public` (although in an internal package), and while it is used correctly in this PR, there's no warning in the doc that `str` and `offset` must come from a trusted caller that ensures that they are safe to use with, well..., Unsafe.
> 
> Did you consider safer alternatives, like usage of `VarHandle`, even if that might mean a slight performance degradation?

Never mind, `VarHandle` cannot be used in this case.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22919#discussion_r1942947089


More information about the core-libs-dev mailing list