mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8187649: ArrayIndexOutOfBoundsException in java.util.JapaneseImperialCalendar
Reviewed-by: joehw, rriggs
This commit is contained in:
parent
ec65cf8332
commit
bea4109ef7
3 changed files with 46 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -886,7 +886,7 @@ class JapaneseImperialCalendar extends Calendar {
|
||||||
} else if (nfd >= (month1 + monthLength)) {
|
} else if (nfd >= (month1 + monthLength)) {
|
||||||
nfd = month1 + monthLength - 1;
|
nfd = month1 + monthLength - 1;
|
||||||
}
|
}
|
||||||
set(DAY_OF_MONTH, (int)(nfd - month1) + 1);
|
set(DAY_OF_MONTH, getCalendarDate(nfd).getDayOfMonth());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1458,7 +1458,7 @@ class JapaneseImperialCalendar extends Calendar {
|
||||||
CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE);
|
CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE);
|
||||||
d.setDate(date.getNormalizedYear(), date.getMonth(), 1);
|
d.setDate(date.getNormalizedYear(), date.getMonth(), 1);
|
||||||
int dayOfWeek = gcal.getDayOfWeek(d);
|
int dayOfWeek = gcal.getDayOfWeek(d);
|
||||||
int monthLength = gcal.getMonthLength(d);
|
int monthLength = actualMonthLength();
|
||||||
dayOfWeek -= getFirstDayOfWeek();
|
dayOfWeek -= getFirstDayOfWeek();
|
||||||
if (dayOfWeek < 0) {
|
if (dayOfWeek < 0) {
|
||||||
dayOfWeek += 7;
|
dayOfWeek += 7;
|
||||||
|
@ -2239,7 +2239,7 @@ class JapaneseImperialCalendar extends Calendar {
|
||||||
private int actualMonthLength() {
|
private int actualMonthLength() {
|
||||||
int length = jcal.getMonthLength(jdate);
|
int length = jcal.getMonthLength(jdate);
|
||||||
int eraIndex = getTransitionEraIndex(jdate);
|
int eraIndex = getTransitionEraIndex(jdate);
|
||||||
if (eraIndex == -1) {
|
if (eraIndex != -1) {
|
||||||
long transitionFixedDate = sinceFixedDates[eraIndex];
|
long transitionFixedDate = sinceFixedDates[eraIndex];
|
||||||
CalendarDate d = eras[eraIndex].getSinceDate();
|
CalendarDate d = eras[eraIndex].getSinceDate();
|
||||||
if (transitionFixedDate <= cachedFixedDate) {
|
if (transitionFixedDate <= cachedFixedDate) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @summary tests Japanese Calendar.
|
* @summary tests Japanese Calendar.
|
||||||
* @bug 4609228
|
* @bug 4609228 8187649
|
||||||
* @modules java.base/sun.util
|
* @modules java.base/sun.util
|
||||||
* java.base/sun.util.calendar
|
* java.base/sun.util.calendar
|
||||||
* @compile
|
* @compile
|
||||||
|
|
|
@ -435,12 +435,48 @@ test roll WEEK_OF_YEAR
|
||||||
check date BeforeMeiji $minyear Dec 25
|
check date BeforeMeiji $minyear Dec 25
|
||||||
|
|
||||||
test WEEK_OF_MONTH
|
test WEEK_OF_MONTH
|
||||||
# Needs to wait for 6191841 fix. (WEEK_OF_MONTH needs to change
|
use jcal
|
||||||
# ERA and YEAR in a transition month.)
|
clear all
|
||||||
|
|
||||||
|
# Make sure this test does not throw AIOOBE
|
||||||
|
set date Heisei 1 Aug 1
|
||||||
|
roll week_of_month 1
|
||||||
|
check date Heisei 1 Aug 8
|
||||||
|
|
||||||
|
# Check transition dates
|
||||||
|
set date Showa 64 Jan 7
|
||||||
|
roll week_of_month 1
|
||||||
|
check date Showa 64 Jan 7
|
||||||
|
roll week_of_month -1
|
||||||
|
check date Showa 64 Jan 7
|
||||||
|
|
||||||
|
set date Heisei 1 Jan 31
|
||||||
|
roll week_of_month 1
|
||||||
|
check date Heisei 1 Jan 10
|
||||||
|
roll week_of_month -1
|
||||||
|
check date Heisei 1 Jan 31
|
||||||
|
|
||||||
test DAY_OF_MONTH
|
test DAY_OF_MONTH
|
||||||
# Needs to wait for 6191841 fix. (DAY_OF_MONTH needs to change
|
use jcal
|
||||||
# ERA and YEAR in a transition month.)
|
clear all
|
||||||
|
|
||||||
|
# Make sure this test does not throw AIOOBE
|
||||||
|
Set date Heisei 1 Aug 1
|
||||||
|
roll day_of_month 1
|
||||||
|
check date Heisei 1 Aug 2
|
||||||
|
|
||||||
|
# Check transition dates
|
||||||
|
set date Showa 64 Jan 7
|
||||||
|
roll day_of_month 1
|
||||||
|
check date Showa 64 Jan 1
|
||||||
|
roll day_of_month -1
|
||||||
|
check date Showa 64 Jan 7
|
||||||
|
|
||||||
|
set date Heisei 1 Jan 31
|
||||||
|
roll day_of_month 1
|
||||||
|
check date Heisei 1 Jan 8
|
||||||
|
roll day_of_month -1
|
||||||
|
check date Heisei 1 Jan 31
|
||||||
|
|
||||||
test DAY_OF_YEAR
|
test DAY_OF_YEAR
|
||||||
use jcal
|
use jcal
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue