mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8181323: Better timezone processing
Reviewed-by: rriggs
This commit is contained in:
parent
e7fdfdb7e7
commit
89b8d98d19
1 changed files with 14 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2017, 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
|
||||||
|
@ -41,6 +41,7 @@ package java.util;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InvalidObjectException;
|
||||||
import sun.util.calendar.CalendarSystem;
|
import sun.util.calendar.CalendarSystem;
|
||||||
import sun.util.calendar.CalendarUtils;
|
import sun.util.calendar.CalendarUtils;
|
||||||
import sun.util.calendar.BaseCalendar;
|
import sun.util.calendar.BaseCalendar;
|
||||||
|
@ -1278,6 +1279,9 @@ public class SimpleTimeZone extends TimeZone {
|
||||||
*/
|
*/
|
||||||
private int serialVersionOnStream = currentSerialVersion;
|
private int serialVersionOnStream = currentSerialVersion;
|
||||||
|
|
||||||
|
// Maximum number of rules.
|
||||||
|
private static final int MAX_RULE_NUM = 6;
|
||||||
|
|
||||||
private synchronized void invalidateCache() {
|
private synchronized void invalidateCache() {
|
||||||
cacheYear = startYear - 1;
|
cacheYear = startYear - 1;
|
||||||
cacheStart = cacheEnd = 0;
|
cacheStart = cacheEnd = 0;
|
||||||
|
@ -1569,7 +1573,7 @@ public class SimpleTimeZone extends TimeZone {
|
||||||
*/
|
*/
|
||||||
private byte[] packRules()
|
private byte[] packRules()
|
||||||
{
|
{
|
||||||
byte[] rules = new byte[6];
|
byte[] rules = new byte[MAX_RULE_NUM];
|
||||||
rules[0] = (byte)startDay;
|
rules[0] = (byte)startDay;
|
||||||
rules[1] = (byte)startDayOfWeek;
|
rules[1] = (byte)startDayOfWeek;
|
||||||
rules[2] = (byte)endDay;
|
rules[2] = (byte)endDay;
|
||||||
|
@ -1594,7 +1598,7 @@ public class SimpleTimeZone extends TimeZone {
|
||||||
endDayOfWeek = rules[3];
|
endDayOfWeek = rules[3];
|
||||||
|
|
||||||
// As of serial version 2, include time modes
|
// As of serial version 2, include time modes
|
||||||
if (rules.length >= 6) {
|
if (rules.length >= MAX_RULE_NUM) {
|
||||||
startTimeMode = rules[4];
|
startTimeMode = rules[4];
|
||||||
endTimeMode = rules[5];
|
endTimeMode = rules[5];
|
||||||
}
|
}
|
||||||
|
@ -1691,9 +1695,13 @@ public class SimpleTimeZone extends TimeZone {
|
||||||
// store the actual rules (which have not be made compatible with 1.1)
|
// store the actual rules (which have not be made compatible with 1.1)
|
||||||
// in the optional area. Read them in here and parse them.
|
// in the optional area. Read them in here and parse them.
|
||||||
int length = stream.readInt();
|
int length = stream.readInt();
|
||||||
byte[] rules = new byte[length];
|
if (length <= MAX_RULE_NUM) {
|
||||||
stream.readFully(rules);
|
byte[] rules = new byte[length];
|
||||||
unpackRules(rules);
|
stream.readFully(rules);
|
||||||
|
unpackRules(rules);
|
||||||
|
} else {
|
||||||
|
throw new InvalidObjectException("Too many rules: " + length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serialVersionOnStream >= 2) {
|
if (serialVersionOnStream >= 2) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue