mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8068278: ArrayIndexOutOfBoundsException instead of DateTimeException in j.t.chrono.JapaneseChronology.eraOf()
Corrected era range check Reviewed-by: mchung, lancea
This commit is contained in:
parent
bb5e8afcf2
commit
ddb472a4dc
2 changed files with 27 additions and 3 deletions
|
@ -195,10 +195,11 @@ public final class JapaneseEra
|
|||
* @throws DateTimeException if the value is invalid
|
||||
*/
|
||||
public static JapaneseEra of(int japaneseEra) {
|
||||
if (japaneseEra < MEIJI.eraValue || japaneseEra + ERA_OFFSET > KNOWN_ERAS.length) {
|
||||
int i = ordinal(japaneseEra);
|
||||
if (i < 0 || i >= KNOWN_ERAS.length) {
|
||||
throw new DateTimeException("Invalid era: " + japaneseEra);
|
||||
}
|
||||
return KNOWN_ERAS[ordinal(japaneseEra)];
|
||||
return KNOWN_ERAS[i];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue