Skip to content

Conversation

@justin-curtis-lu
Copy link
Member

@justin-curtis-lu justin-curtis-lu commented Feb 25, 2025

Please review this PR which prevents an AIOOBE from leaking out when java.util.Calendar.Builder is used to build a Japanese calendar with an era value too large.

Note that we don't check under BEFORE_MEIJI/0 as historically Japanese calendar ignores negative values during normalization. See JapaneseImperialCalendar L2018: date.setEra(era > 0 ? eras[era] : null);.

We also check against eras.length over REIWA/5 due to the possibility of additional eras via the property override or future eras in general.


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
  • Change requires CSR request JDK-8350806 to be approved

Issues

  • JDK-8350646: Calendar.Builder.build() Throws ArrayIndexOutOfBoundsException (Bug - P4)
  • JDK-8350806: Calendar.Builder.build() Throws ArrayIndexOutOfBoundsException (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23789

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 25, 2025

👋 Welcome back jlu! 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 Feb 25, 2025

@justin-curtis-lu This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8350646: Calendar.Builder.build() Throws ArrayIndexOutOfBoundsException

Reviewed-by: naoto

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 40 new commits pushed to the master branch:

  • ab4b0ef: 8350889: GenShen: Break out of infinite loop of old GC cycles
  • 0a4c5a8: 8347804: GenShen: Crash with small GCCardSizeInBytes and small Java heap
  • f1398ec: 8350701: [JMH] test foreign.AllocFromSliceTest failed with Exception for size>1024
  • 3ae80bf: 8349766: GenShen: Bad progress after degen does not always need full gc
  • 2fd7156: 8347426: Invalid value used for enum Cell in iTypeFlow::StateVector::meet_exception
  • 939815f: 8347040: C2: assert(!loop->_body.contains(in)) failed
  • 8323ddf: 8346659: SnippetTaglet should report an error if provided ambiguous links
  • 3c9d64e: 8350858: [IR Framework] Some tests failed on Cascade Lake
  • d6d9447: 8350786: Some java/lang jtreg tests miss requires vm.hasJFR
  • e80b76b: 8276995: Bug in jdk.jfr.event.gc.collection.TestSystemGC
  • ... and 30 more: https://git.openjdk.org/jdk/compare/2efb0336e0c257c34f9e49a50cbad1704691582e...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8350646: Calendar.Builder.build() Throws ArrayIndexOutOfBoundsException 8350646: Calendar.Builder.build() Throws ArrayIndexOutOfBoundsException Feb 25, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 25, 2025
@openjdk
Copy link

openjdk bot commented Feb 25, 2025

@justin-curtis-lu The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

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.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels Feb 25, 2025
@mlbridge
Copy link

mlbridge bot commented Feb 26, 2025

Webrevs

@liach
Copy link
Member

liach commented Feb 26, 2025

This appears to be a behavioral change and warrants a CSR.

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I would expect a test case with jdk.calendar.japanese.supplemental.era defined with something, and 7 would throw an IAE.

Comment on lines 1861 to 1862
// We check against eras.length over Reiwa ERA due to possibility
// of additional eras via "jdk.calendar.japanese.supplemental.era"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The possibility is not only that emergency property, but by design Japanese calendar eras increase when the current emperor abdicates.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Feb 26, 2025
@justin-curtis-lu
Copy link
Member Author

@naotoj Addressed your comments in e55053a.

@liach Filed a CSR: https://bugs.openjdk.org/browse/JDK-8350806.

try {
new Calendar.Builder()
.setCalendarType("japanese")
.setFields(ERA, 7)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I suggested this immediate value "7", but this can be JapaneseEra.values().length + 2 which might be more meaningful

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that is better; it's pushed.

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I reviewed the CSR as well.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Feb 28, 2025
@justin-curtis-lu
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 28, 2025

Going to push as commit 3a7d986.
Since your change was applied there have been 47 commits pushed to the master branch:

  • 197004f: 8350820: OperatingSystemMXBean CpuLoad() methods return -1.0 on Windows
  • e98df71: 8348028: Unable to run gtests with CDS enabled
  • d6c4be6: 8350758: G1: Use actual last prediction in accumulated survivor rate prediction too
  • 2019f44: 8343832: Enhance test summary with number of skipped tests
  • ac76d8d: 8350824: New async logging gtest StallingModePreventsDroppedMessages fails
  • eada1ea: 8350855: RISC-V: print offset by assert of patch_offset_in_conditional_branch
  • 2af76de: 8350683: Non-C2 / minimal JVM crashes in the build on ppc64 platforms
  • ab4b0ef: 8350889: GenShen: Break out of infinite loop of old GC cycles
  • 0a4c5a8: 8347804: GenShen: Crash with small GCCardSizeInBytes and small Java heap
  • f1398ec: 8350701: [JMH] test foreign.AllocFromSliceTest failed with Exception for size>1024
  • ... and 37 more: https://git.openjdk.org/jdk/compare/2efb0336e0c257c34f9e49a50cbad1704691582e...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 28, 2025
@openjdk openjdk bot closed this Feb 28, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 28, 2025
@openjdk
Copy link

openjdk bot commented Feb 28, 2025

@justin-curtis-lu Pushed as commit 3a7d986.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants