Skip to content

Commit

Permalink
8273924: ArrayIndexOutOfBoundsException thrown in java.util.JapaneseI…
Browse files Browse the repository at this point in the history
…mperialCalendar.add()

Reviewed-by: rriggs, iris, joehw
  • Loading branch information
naotoj committed Sep 22, 2021
1 parent c9de806 commit d39aad9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -277,6 +277,10 @@ void normalizeMonth(CalendarDate date) {
long xm = 1L - month;
year -= (int)((xm / 12) + 1);
month = 13 - (xm % 12);
if (month == 13) {
year++;
month = 1;
}
bdate.setNormalizedYear(year);
bdate.setMonth((int) month);
} else if (month > DECEMBER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/*
* @test
* @summary tests Japanese Calendar.
* @bug 4609228 8187649
* @bug 4609228 8187649 8273924
* @modules java.base/sun.util
* java.base/sun.util.calendar
* @compile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,26 @@ test add MONTH
# check date Heisei $max Aug 16
# check timeofday 23 59 59 999

# JDK-8273924
set date Reiwa 2 Mar 1
add month -10
check date Reiwa 1 May 1
set date Reiwa 2 Mar 1
add month -11
check date Heisei 31 Apr 1
set date Reiwa 2 Mar 1
add month -12
check date Heisei 31 Mar 1
set date Reiwa 2 Mar 1
add month -13
check date Heisei 31 Feb 1
set date Reiwa 2 Mar 1
add month -14
check date Heisei 31 Jan 1
set date Reiwa 2 Mar 1
add month -15
check date Heisei 30 Dec 1

test add WEEK_OF_YEAR
use jcal
clear all
Expand Down

3 comments on commit d39aad9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@TheRealMDoerr
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d39aad9 Oct 5, 2021

Choose a reason for hiding this comment

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

@TheRealMDoerr the backport was successfully created on the branch TheRealMDoerr-backport-d39aad92 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit d39aad92 from the openjdk/jdk repository.

The commit being backported was authored by Naoto Sato on 22 Sep 2021 and was reviewed by Roger Riggs, Iris Clark and Joe Wang.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev TheRealMDoerr-backport-d39aad92:TheRealMDoerr-backport-d39aad92
$ git checkout TheRealMDoerr-backport-d39aad92
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev TheRealMDoerr-backport-d39aad92

Please sign in to comment.