mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 09:53:18 +00:00
8273924: ArrayIndexOutOfBoundsException thrown in java.util.JapaneseImperialCalendar.add()
Reviewed-by: rriggs, iris, joehw
This commit is contained in:
parent
c9de80635e
commit
d39aad9230
@ -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 @@ public abstract class BaseCalendar extends AbstractCalendar {
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user