On Thu, 14 Nov 2024 05:32:34 GMT, Shaojin Wen <s...@openjdk.org> wrote:

> The type of the Unsafe base offset constant is int, which may cause overflow 
> when adding int offsets, such as 8343925 (PR #22012). 8343984 (PR #22027) 
> fixes most of the offset overflows in JDK, but ArraysSupport and CRC32C are 
> still unfixed.
> 
> @liach proposed the idea of ​​changing the Unsafe base offset to long, which 
> is a complete solution to the Unsafe offset overflow. After discussing with 
> @liach, I submitted this PR to implement @liach's idea.

src/java.base/share/classes/jdk/internal/foreign/Utils.java line 316:

> 314:                 new BaseAndScale((int) Unsafe.ARRAY_LONG_BASE_OFFSET, 
> Unsafe.ARRAY_LONG_INDEX_SCALE);
> 315:         public static final BaseAndScale DOUBLE =
> 316:                 new BaseAndScale((int) Unsafe.ARRAY_DOUBLE_BASE_OFFSET, 
> Unsafe.ARRAY_DOUBLE_INDEX_SCALE);

I'd rather the `base` field be change to `long` instead of introducing cast 
here. Otherwise users of this class will have the same issue.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22095#discussion_r1842658935

Reply via email to