Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8341243: Use ArraySupport.SOFT_MAX_ARRAY_LENGTH for max array size in java.base #21268

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

eirbjo
Copy link
Contributor

@eirbjo eirbjo commented Sep 30, 2024

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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8341243: Use ArraySupport.SOFT_MAX_ARRAY_LENGTH for max array size in java.base (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21268/head:pull/21268
$ git checkout pull/21268

Update a local copy of the PR:
$ git checkout pull/21268
$ git pull https://git.openjdk.org/jdk.git pull/21268/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21268

View PR using the GUI difftool:
$ git pr show -t 21268

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21268.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 30, 2024

👋 Welcome back eirbjo! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 30, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Sep 30, 2024

@eirbjo The following labels will be automatically applied to this pull request:

  • core-libs
  • nio
  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@eirbjo eirbjo marked this pull request as ready for review September 30, 2024 19:10
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 30, 2024
@mlbridge
Copy link

mlbridge bot commented Sep 30, 2024

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant