Skip to content
Permalink
Browse files
8273924: ArrayIndexOutOfBoundsException thrown in java.util.JapaneseI…
…mperialCalendar.add()

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

1 comment on commit c4b3d62

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on c4b3d62 Sep 29, 2021

Please sign in to comment.