--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java Tue Feb 12 16:02:14 2013 +0400
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java Tue Feb 12 09:25:43 2013 -0800
@@ -30,10 +30,12 @@
import java.lang.ref.SoftReference;
import java.security.AccessController;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
@@ -78,19 +80,6 @@
private static final long ABBR_MASK = 0xf00L;
private static final int TRANSITION_NSHIFT = 12;
- // Flag for supporting JDK backward compatible IDs, such as "EST".
- static final boolean USE_OLDMAPPING;
- static {
- String oldmapping = AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT);
- USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
- }
-
- // IDs having conflicting data between Olson and JDK 1.1
- static final String[] conflictingIDs = {
- "EST", "MST", "HST"
- };
-
private static final CalendarSystem gcal = CalendarSystem.getGregorianCalendar();
/**
@@ -521,7 +510,7 @@
SimpleTimeZone tz = getLastRule();
if (tz != null) {
return tz.inDaylightTime(date);
- }
+ }
return false;
}
@@ -572,17 +561,8 @@
* @return an array of time zone IDs.
*/
public static String[] getAvailableIDs() {
- List<String> idList = ZoneInfoFile.getZoneIDs();
- List<String> excluded = ZoneInfoFile.getExcludedZones();
- if (excluded != null) {
- // List all zones from the idList and excluded lists
- List<String> list = new ArrayList<>(idList.size() + excluded.size());
- list.addAll(idList);
- list.addAll(excluded);
- idList = list;
- }
- String[] ids = new String[idList.size()];
- return idList.toArray(ids);
+ Set<String> idSet = ZoneInfoFile.getZoneIds();
+ return idSet.toArray(new String[idSet.size()]);
}
/**
@@ -595,45 +575,7 @@
* @return an array of time zone IDs.
*/
public static String[] getAvailableIDs(int rawOffset) {
- String[] result;
- List<String> matched = new ArrayList<>();
- List<String> IDs = ZoneInfoFile.getZoneIDs();
- int[] rawOffsets = ZoneInfoFile.getRawOffsets();
-
- loop:
- for (int index = 0; index < rawOffsets.length; index++) {
- if (rawOffsets[index] == rawOffset) {
- byte[] indices = ZoneInfoFile.getRawOffsetIndices();
- for (int i = 0; i < indices.length; i++) {
- if (indices[i] == index) {
- matched.add(IDs.get(i++));
- while (i < indices.length && indices[i] == index) {
- matched.add(IDs.get(i++));
- }
- break loop;
- }
- }
- }
- }
-
- // We need to add any zones from the excluded zone list that
- // currently have the same GMT offset as the specified
- // rawOffset. The zones returned by this method may not be
- // correct as of return to the caller if any GMT offset
- // transition is happening during this GMT offset checking...
- List<String> excluded = ZoneInfoFile.getExcludedZones();
- if (excluded != null) {
- for (String id : excluded) {
- TimeZone zi = getTimeZone(id);
- if (zi != null && zi.getRawOffset() == rawOffset) {
- matched.add(id);
- }
- }
- }
-
- result = new String[matched.size()];
- matched.toArray(result);
- return result;
+ return ZoneInfoFile.getZoneIds(rawOffset);
}
/**
@@ -645,44 +587,7 @@
* time zone of the ID.
*/
public static TimeZone getTimeZone(String ID) {
- String givenID = null;
-
- /*
- * If old JDK compatibility is specified, get the old alias
- * name.
- */
- if (USE_OLDMAPPING) {
- String compatibleID = TzIDOldMapping.MAP.get(ID);
- if (compatibleID != null) {
- givenID = ID;
- ID = compatibleID;
- }
- }
-
- ZoneInfo zi = ZoneInfoFile.getZoneInfo(ID);
- if (zi == null) {
- // if we can't create an object for the ID, try aliases.
- try {
- Map<String, String> map = getAliasTable();
- String alias = ID;
- while ((alias = map.get(alias)) != null) {
- zi = ZoneInfoFile.getZoneInfo(alias);
- if (zi != null) {
- zi.setID(ID);
- zi = ZoneInfoFile.addToCache(ID, zi);
- zi = (ZoneInfo) zi.clone();
- break;
- }
- }
- } catch (Exception e) {
- // ignore exceptions
- }
- }
-
- if (givenID != null && zi != null) {
- zi.setID(givenID);
- }
- return zi;
+ return ZoneInfoFile.getZoneInfo(ID);
}
private transient SimpleTimeZone lastRule;
@@ -811,18 +716,6 @@
return (checksum == ((ZoneInfo)other).checksum);
}
- private static SoftReference<Map<String, String>> aliasTable;
-
- static Map<String, String> getCachedAliasTable() {
- Map<String, String> aliases = null;
-
- SoftReference<Map<String, String>> cache = aliasTable;
- if (cache != null) {
- aliases = cache.get();
- }
- return aliases;
- }
-
/**
* Returns a Map from alias time zone IDs to their standard
* time zone IDs.
@@ -831,22 +724,9 @@
* to their standard time zone IDs, or null if
* <code>ZoneInfoMappings</code> file is not available.
*/
- public synchronized static Map<String, String> getAliasTable() {
- Map<String, String> aliases = getCachedAliasTable();
- if (aliases == null) {
- aliases = ZoneInfoFile.getZoneAliases();
- if (aliases != null) {
- if (!USE_OLDMAPPING) {
- // Remove the conflicting IDs from the alias table.
- for (String key : conflictingIDs) {
- aliases.remove(key);
- }
- }
- aliasTable = new SoftReference<Map<String, String>>(aliases);
- }
- }
- return aliases;
- }
+ public static Map<String, String> getAliasTable() {
+ return ZoneInfoFile.getAliasMap();
+ }
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {