> Please review this cleanup PR which updates code and tests in `java.base` to 
> consistently use  `jdk.internal.util.ArraySupport.SOFT_MAX_ARRAY_LENGTH` when 
> referring to the JVM's maximum array size implementation limit. Currently, 
> instances of `Integer.MAX_VALUE - 8` are found across the code base, with 
> varying degrees of documentation. It would be good to consolidate on a single 
> source of truth, with proper documentation.
> 
> This PR is a follow-up to #20905 where the same change was requested in 
> `java.util.zip`.
> 
> My understanding is that javac will fold this constant value into the byte 
> code of the compiled use sites, as such this change should not affect class 
> loading or cause startup issues. 
> 
> Instances selected for this PR were found searching for "Integer.MAX_VALUE - 
> 8". The PR replaces these with `ArraySupport.SOFT_MAX_ARRAY_LENGTH`, while 
> trimming or amending some code comments where appropriate. 
> (`SOFT_MAX_ARRAY_LENGTH` already has a good explainer which does not need 
> repetition at each use site).
> 
> I also searched for instances of `Integer.MAX_VALUE - 1` and 
> `Integer.MAX_VALUE - 2`, no convincing candidates were found.
> 
> Instances outside `java.base` were deliberately left out to limit the scope 
> and review cost of this PR.
> 
> Tests updated to use `SOFT_MAX_ARRAY_LENGTH` are updated with the jtreg tag 
> `@modules java.base/jdk.internal.util`.
> 
> Testing: No new tests are added in this PR, the `noreg-cleanup` label is 
> added to the JBS. The five affected tests have been run manually. GHA tests 
> run green.

Eirik Bjørsnøs has updated the pull request incrementally with one additional 
commit since the last revision:

  Remove comment and variable from HugeCapacity tests

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/21268/files
  - new: https://git.openjdk.org/jdk/pull/21268/files/eb1c6551..67ed8e47

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=21268&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21268&range=00-01

  Stats: 6 lines in 2 files changed: 0 ins; 4 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/21268.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21268/head:pull/21268

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

Reply via email to