mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +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.
|
||||
*
|
||||
* 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)) {
|
||||
nfd = month1 + monthLength - 1;
|
||||
}
|
||||
set(DAY_OF_MONTH, (int)(nfd - month1) + 1);
|
||||
set(DAY_OF_MONTH, getCalendarDate(nfd).getDayOfMonth());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1458,7 +1458,7 @@ class JapaneseImperialCalendar extends Calendar {
|
|||
CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE);
|
||||
d.setDate(date.getNormalizedYear(), date.getMonth(), 1);
|
||||
int dayOfWeek = gcal.getDayOfWeek(d);
|
||||
int monthLength = gcal.getMonthLength(d);
|
||||
int monthLength = actualMonthLength();
|
||||
dayOfWeek -= getFirstDayOfWeek();
|
||||
if (dayOfWeek < 0) {
|
||||
dayOfWeek += 7;
|
||||
|
@ -2239,7 +2239,7 @@ class JapaneseImperialCalendar extends Calendar {
|
|||
private int actualMonthLength() {
|
||||
int length = jcal.getMonthLength(jdate);
|
||||
int eraIndex = getTransitionEraIndex(jdate);
|
||||
if (eraIndex == -1) {
|
||||
if (eraIndex != -1) {
|
||||
long transitionFixedDate = sinceFixedDates[eraIndex];
|
||||
CalendarDate d = eras[eraIndex].getSinceDate();
|
||||
if (transitionFixedDate <= cachedFixedDate) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue