RFR: 8344168: Change Unsafe base offset from int to long [v5]

Shaojin Wen swen at openjdk.org
Sat Jan 25 16:15:38 UTC 2025


> 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.

Shaojin Wen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:

 - fix DecimalDigits
 - Merge remote-tracking branch 'upstream/master' into long_unsafe_offset_202411
 - Typos
 - Fix type expectations
 - Make base offset method and invalid offset long
 - Merge remote-tracking branch 'upstream/master' into long_unsafe_offset_202411
 - long BaseAndScale base, from @JornVernee
 - long Unsafe offset

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/22095/files
  - new: https://git.openjdk.org/jdk/pull/22095/files/6d4bb369..76f6f3fb

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=22095&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=22095&range=03-04

  Stats: 287804 lines in 7071 files changed: 168735 ins; 95338 del; 23731 mod
  Patch: https://git.openjdk.org/jdk/pull/22095.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22095/head:pull/22095

PR: https://git.openjdk.org/jdk/pull/22095


More information about the core-libs-dev mailing list