< prev index next >

src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


 228         { "CNT", "America/St_Johns" },
 229         { "CST", "America/Chicago" },
 230         { "CTT", "Asia/Shanghai" },
 231         { "EAT", "Africa/Addis_Ababa" },
 232         { "ECT", "Europe/Paris" },
 233         { "IET", "America/Indiana/Indianapolis" },
 234         { "IST", "Asia/Kolkata" },
 235         { "JST", "Asia/Tokyo" },
 236         { "MIT", "Pacific/Apia" },
 237         { "NET", "Asia/Yerevan" },
 238         { "NST", "Pacific/Auckland" },
 239         { "PLT", "Asia/Karachi" },
 240         { "PNT", "America/Phoenix" },
 241         { "PRT", "America/Puerto_Rico" },
 242         { "PST", "America/Los_Angeles" },
 243         { "SST", "Pacific/Guadalcanal" },
 244         { "VST", "Asia/Ho_Chi_Minh" },
 245     };
 246 
 247     static {
 248         String oldmapping = AccessController.doPrivileged(
 249             new GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT);
 250         USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
 251         AccessController.doPrivileged(new PrivilegedAction<Object>() {
 252             public Object run() {
 253                 try {
 254                     String libDir = System.getProperty("java.home") + File.separator + "lib";
 255                     try (DataInputStream dis = new DataInputStream(
 256                              new BufferedInputStream(new FileInputStream(
 257                                  new File(libDir, "tzdb.dat"))))) {
 258                         load(dis);
 259                     }
 260                 } catch (Exception x) {
 261                     throw new Error(x);
 262                 }
 263                 return null;


 264             }
 265         });
 266     }
 267 
 268     private static void addOldMapping() {
 269         for (String[] alias : oldMappings) {
 270             aliases.put(alias[0], alias[1]);
 271         }
 272         if (USE_OLDMAPPING) {
 273             aliases.put("EST", "America/New_York");
 274             aliases.put("MST", "America/Denver");
 275             aliases.put("HST", "Pacific/Honolulu");
 276         } else {
 277             zones.put("EST", new ZoneInfo("EST", -18000000));
 278             zones.put("MST", new ZoneInfo("MST", -25200000));
 279             zones.put("HST", new ZoneInfo("HST", -36000000));
 280         }
 281     }
 282 
 283     public static boolean useOldMapping() {




 228         { "CNT", "America/St_Johns" },
 229         { "CST", "America/Chicago" },
 230         { "CTT", "Asia/Shanghai" },
 231         { "EAT", "Africa/Addis_Ababa" },
 232         { "ECT", "Europe/Paris" },
 233         { "IET", "America/Indiana/Indianapolis" },
 234         { "IST", "Asia/Kolkata" },
 235         { "JST", "Asia/Tokyo" },
 236         { "MIT", "Pacific/Apia" },
 237         { "NET", "Asia/Yerevan" },
 238         { "NST", "Pacific/Auckland" },
 239         { "PLT", "Asia/Karachi" },
 240         { "PNT", "America/Phoenix" },
 241         { "PRT", "America/Puerto_Rico" },
 242         { "PST", "America/Los_Angeles" },
 243         { "SST", "Pacific/Guadalcanal" },
 244         { "VST", "Asia/Ho_Chi_Minh" },
 245     };
 246 
 247     static {
 248         USE_OLDMAPPING = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
 249             public Boolean run() {



 250                 try {
 251                     String libDir = System.getProperty("java.home") + File.separator + "lib";
 252                     try (DataInputStream dis = new DataInputStream(
 253                              new BufferedInputStream(new FileInputStream(
 254                                  new File(libDir, "tzdb.dat"))))) {
 255                         load(dis);
 256                     }
 257                 } catch (Exception x) {
 258                     throw new Error(x);
 259                 }
 260                 String oldmapping = System.getProperty("sun.timezone.ids.oldmapping", "false")
 261                     .toLowerCase(Locale.ROOT);
 262                 return (oldmapping.equals("yes") || oldmapping.equals("true"));
 263             }
 264         });
 265     }
 266 
 267     private static void addOldMapping() {
 268         for (String[] alias : oldMappings) {
 269             aliases.put(alias[0], alias[1]);
 270         }
 271         if (USE_OLDMAPPING) {
 272             aliases.put("EST", "America/New_York");
 273             aliases.put("MST", "America/Denver");
 274             aliases.put("HST", "Pacific/Honolulu");
 275         } else {
 276             zones.put("EST", new ZoneInfo("EST", -18000000));
 277             zones.put("MST", new ZoneInfo("MST", -25200000));
 278             zones.put("HST", new ZoneInfo("HST", -36000000));
 279         }
 280     }
 281 
 282     public static boolean useOldMapping() {


< prev index next >