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()

Backport-of: d39aad92308fbc28bd2de164e331062ebf62da85
  • Loading branch information
Yoshiki Sato authored and coffeys committed Sep 29, 2021
1 parent f4a0b13 commit c4b3d62
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

1 comment on commit c4b3d62

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.