1.1 --- a/rt/emul/compact/src/main/java/java/util/TimeZone.java Thu Oct 03 15:40:35 2013 +0200
1.2 +++ b/rt/emul/compact/src/main/java/java/util/TimeZone.java Tue May 10 04:52:05 2016 +0200
1.3 @@ -43,10 +43,6 @@
1.4 import java.security.AccessController;
1.5 import java.security.PrivilegedAction;
1.6 import java.util.concurrent.ConcurrentHashMap;
1.7 -import sun.security.action.GetPropertyAction;
1.8 -import sun.util.TimeZoneNameUtility;
1.9 -import sun.util.calendar.ZoneInfo;
1.10 -import sun.util.calendar.ZoneInfoFile;
1.11
1.12 /**
1.13 * <code>TimeZone</code> represents a time zone offset, and also figures out daylight
1.14 @@ -411,7 +407,7 @@
1.15 if (daylight) {
1.16 offset += getDSTSavings();
1.17 }
1.18 - return ZoneInfoFile.toCustomID(offset);
1.19 + // return ZoneInfoFile.toCustomID(offset);
1.20 }
1.21
1.22 int index = daylight ? 3 : 1;
1.23 @@ -440,7 +436,7 @@
1.24 if (names != null) {
1.25 return names;
1.26 }
1.27 - names = TimeZoneNameUtility.retrieveDisplayNames(id, locale);
1.28 + names = null; // TimeZoneNameUtility.retrieveDisplayNames(id, locale);
1.29 if (names != null) {
1.30 perLocale.put(locale, names);
1.31 }
1.32 @@ -448,7 +444,7 @@
1.33 }
1.34 }
1.35
1.36 - String[] names = TimeZoneNameUtility.retrieveDisplayNames(id, locale);
1.37 + String[] names = null; // TimeZoneNameUtility.retrieveDisplayNames(id, locale);
1.38 if (names != null) {
1.39 Map<Locale, String[]> perLocale = new ConcurrentHashMap<Locale, String[]>();
1.40 perLocale.put(locale, names);
1.41 @@ -556,14 +552,15 @@
1.42 }
1.43
1.44 private static TimeZone getTimeZone(String ID, boolean fallback) {
1.45 - TimeZone tz = ZoneInfo.getTimeZone(ID);
1.46 - if (tz == null) {
1.47 - tz = parseCustomTimeZone(ID);
1.48 - if (tz == null && fallback) {
1.49 - tz = new ZoneInfo(GMT_ID, 0);
1.50 - }
1.51 - }
1.52 - return tz;
1.53 +// TimeZone tz = ZoneInfo.getTimeZone(ID);
1.54 +// if (tz == null) {
1.55 +// tz = parseCustomTimeZone(ID);
1.56 +// if (tz == null && fallback) {
1.57 +// tz = new ZoneInfo(GMT_ID, 0);
1.58 +// }
1.59 +// }
1.60 +// return tz;
1.61 + return TimeZone.NO_TIMEZONE;
1.62 }
1.63
1.64 /**
1.65 @@ -576,7 +573,7 @@
1.66 * @see #getRawOffset()
1.67 */
1.68 public static synchronized String[] getAvailableIDs(int rawOffset) {
1.69 - return ZoneInfo.getAvailableIDs(rawOffset);
1.70 + return new String[0];//ZoneInfo.getAvailableIDs(rawOffset);
1.71 }
1.72
1.73 /**
1.74 @@ -584,7 +581,7 @@
1.75 * @return an array of IDs.
1.76 */
1.77 public static synchronized String[] getAvailableIDs() {
1.78 - return ZoneInfo.getAvailableIDs();
1.79 + return new String[0];//return ZoneInfo.getAvailableIDs();
1.80 }
1.81
1.82 /**
1.83 @@ -615,12 +612,12 @@
1.84 * method doesn't create a clone.
1.85 */
1.86 static TimeZone getDefaultRef() {
1.87 - TimeZone defaultZone = defaultZoneTL.get();
1.88 + TimeZone defaultZone = null;//defaultZoneTL.get();
1.89 if (defaultZone == null) {
1.90 defaultZone = defaultTimeZone;
1.91 if (defaultZone == null) {
1.92 // Need to initialize the default time zone.
1.93 - defaultZone = setDefaultZone();
1.94 + defaultZone = TimeZone.NO_TIMEZONE;
1.95 assert defaultZone != null;
1.96 }
1.97 }
1.98 @@ -628,68 +625,8 @@
1.99 return defaultZone;
1.100 }
1.101
1.102 - private static synchronized TimeZone setDefaultZone() {
1.103 - TimeZone tz = null;
1.104 - // get the time zone ID from the system properties
1.105 - String zoneID = AccessController.doPrivileged(
1.106 - new GetPropertyAction("user.timezone"));
1.107 -
1.108 - // if the time zone ID is not set (yet), perform the
1.109 - // platform to Java time zone ID mapping.
1.110 - if (zoneID == null || zoneID.equals("")) {
1.111 - String country = AccessController.doPrivileged(
1.112 - new GetPropertyAction("user.country"));
1.113 - String javaHome = AccessController.doPrivileged(
1.114 - new GetPropertyAction("java.home"));
1.115 - try {
1.116 - zoneID = getSystemTimeZoneID(javaHome, country);
1.117 - if (zoneID == null) {
1.118 - zoneID = GMT_ID;
1.119 - }
1.120 - } catch (NullPointerException e) {
1.121 - zoneID = GMT_ID;
1.122 - }
1.123 - }
1.124 -
1.125 - // Get the time zone for zoneID. But not fall back to
1.126 - // "GMT" here.
1.127 - tz = getTimeZone(zoneID, false);
1.128 -
1.129 - if (tz == null) {
1.130 - // If the given zone ID is unknown in Java, try to
1.131 - // get the GMT-offset-based time zone ID,
1.132 - // a.k.a. custom time zone ID (e.g., "GMT-08:00").
1.133 - String gmtOffsetID = getSystemGMTOffsetID();
1.134 - if (gmtOffsetID != null) {
1.135 - zoneID = gmtOffsetID;
1.136 - }
1.137 - tz = getTimeZone(zoneID, true);
1.138 - }
1.139 - assert tz != null;
1.140 -
1.141 - final String id = zoneID;
1.142 - AccessController.doPrivileged(new PrivilegedAction<Object>() {
1.143 - public Object run() {
1.144 - System.setProperty("user.timezone", id);
1.145 - return null;
1.146 - }
1.147 - });
1.148 -
1.149 - defaultTimeZone = tz;
1.150 - return tz;
1.151 - }
1.152 -
1.153 private static boolean hasPermission() {
1.154 - boolean hasPermission = true;
1.155 - SecurityManager sm = System.getSecurityManager();
1.156 - if (sm != null) {
1.157 - try {
1.158 - sm.checkPermission(new PropertyPermission
1.159 - ("user.timezone", "write"));
1.160 - } catch (SecurityException e) {
1.161 - hasPermission = false;
1.162 - }
1.163 - }
1.164 + boolean hasPermission = false;
1.165 return hasPermission;
1.166 }
1.167
1.168 @@ -706,10 +643,10 @@
1.169 if (hasPermission()) {
1.170 synchronized (TimeZone.class) {
1.171 defaultTimeZone = zone;
1.172 - defaultZoneTL.set(null);
1.173 + // defaultZoneTL.set(null);
1.174 }
1.175 } else {
1.176 - defaultZoneTL.set(zone);
1.177 + //defaultZoneTL.set(zone);
1.178 }
1.179 }
1.180
1.181 @@ -760,8 +697,6 @@
1.182 */
1.183 private String ID;
1.184 private static volatile TimeZone defaultTimeZone;
1.185 - private static final InheritableThreadLocal<TimeZone> defaultZoneTL
1.186 - = new InheritableThreadLocal<TimeZone>();
1.187
1.188 static final String GMT_ID = "GMT";
1.189 private static final int GMT_ID_LENGTH = 3;
1.190 @@ -775,90 +710,6 @@
1.191 * no daylight saving time, or null if the id cannot be parsed.
1.192 */
1.193 private static final TimeZone parseCustomTimeZone(String id) {
1.194 - int length;
1.195 -
1.196 - // Error if the length of id isn't long enough or id doesn't
1.197 - // start with "GMT".
1.198 - if ((length = id.length()) < (GMT_ID_LENGTH + 2) ||
1.199 - id.indexOf(GMT_ID) != 0) {
1.200 - return null;
1.201 - }
1.202 -
1.203 - ZoneInfo zi;
1.204 -
1.205 - // First, we try to find it in the cache with the given
1.206 - // id. Even the id is not normalized, the returned ZoneInfo
1.207 - // should have its normalized id.
1.208 - zi = ZoneInfoFile.getZoneInfo(id);
1.209 - if (zi != null) {
1.210 - return zi;
1.211 - }
1.212 -
1.213 - int index = GMT_ID_LENGTH;
1.214 - boolean negative = false;
1.215 - char c = id.charAt(index++);
1.216 - if (c == '-') {
1.217 - negative = true;
1.218 - } else if (c != '+') {
1.219 - return null;
1.220 - }
1.221 -
1.222 - int hours = 0;
1.223 - int num = 0;
1.224 - int countDelim = 0;
1.225 - int len = 0;
1.226 - while (index < length) {
1.227 - c = id.charAt(index++);
1.228 - if (c == ':') {
1.229 - if (countDelim > 0) {
1.230 - return null;
1.231 - }
1.232 - if (len > 2) {
1.233 - return null;
1.234 - }
1.235 - hours = num;
1.236 - countDelim++;
1.237 - num = 0;
1.238 - len = 0;
1.239 - continue;
1.240 - }
1.241 - if (c < '0' || c > '9') {
1.242 - return null;
1.243 - }
1.244 - num = num * 10 + (c - '0');
1.245 - len++;
1.246 - }
1.247 - if (index != length) {
1.248 - return null;
1.249 - }
1.250 - if (countDelim == 0) {
1.251 - if (len <= 2) {
1.252 - hours = num;
1.253 - num = 0;
1.254 - } else {
1.255 - hours = num / 100;
1.256 - num %= 100;
1.257 - }
1.258 - } else {
1.259 - if (len != 2) {
1.260 - return null;
1.261 - }
1.262 - }
1.263 - if (hours > 23 || num > 59) {
1.264 - return null;
1.265 - }
1.266 - int gmtOffset = (hours * 60 + num) * 60 * 1000;
1.267 -
1.268 - if (gmtOffset == 0) {
1.269 - zi = ZoneInfoFile.getZoneInfo(GMT_ID);
1.270 - if (negative) {
1.271 - zi.setID("GMT-00:00");
1.272 - } else {
1.273 - zi.setID("GMT+00:00");
1.274 - }
1.275 - } else {
1.276 - zi = ZoneInfoFile.getCustomTimeZone(id, negative ? -gmtOffset : gmtOffset);
1.277 - }
1.278 - return zi;
1.279 + return null;
1.280 }
1.281 }