34 private static final String MAPPING_PROPERTY_NAME = "sun.timezone.ids.oldmapping";
35 private static final Map<String, String> newmap = new HashMap<String, String>();
36 static {
37 // Add known new mappings
38 newmap.put("EST", "EST");
39 newmap.put("MST", "MST");
40 newmap.put("HST", "HST");
41 }
42
43 public static void main(String[] args) {
44 boolean useOldMapping = true;
45 String arg = args[0];
46 if (arg.equals("-new")) {
47 useOldMapping = false;
48 } else if (arg.equals("-old")) {
49 useOldMapping = true;
50 } else {
51 throw new RuntimeException("-old or -new must be specified; got " + arg);
52 }
53
54 // Get a Field for TzIDOldMapping in sun.util.calendar.
55 Map<String, String> oldmap = null;
56 try {
57 Class<?> oldmapClass = Class.forName("sun.util.calendar.TzIDOldMapping");
58 Field map = oldmapClass.getDeclaredField("MAP");
59 map.setAccessible(true);
60 oldmap = (Map<String, String>) map.get(null);
61 } catch (Exception e) {
62 throw new RuntimeException("can't get TzIDOldMapping.MAP", e);
63 }
64
65 String prop = System.getProperty(MAPPING_PROPERTY_NAME);
66 System.out.println(MAPPING_PROPERTY_NAME + "=" + prop);
67
68 // Try the test multiple times with modifying TimeZones to
69 // make sure TimeZone instances for the old mapping are
70 // properly copied (defensive copy).
71 for (int count = 0; count < 3; count++) {
72 for (String id : oldmap.keySet()) {
73 TimeZone tzAlias = TimeZone.getTimeZone(id);
74 TimeZone tz = TimeZone.getTimeZone(oldmap.get(id));
75 if (useOldMapping) {
76 if (!tzAlias.hasSameRules(tz)) {
77 throw new RuntimeException("OLDMAP: " + MAPPING_PROPERTY_NAME + "=" + prop + ": "
78 + id + " isn't an alias of " + oldmap.get(id));
79 }
80 if (count == 0) {
81 System.out.println(" " + id + " => " + oldmap.get(id));
82 }
83 tzAlias.setRawOffset(tzAlias.getRawOffset() * count);
84 } else {
|
34 private static final String MAPPING_PROPERTY_NAME = "sun.timezone.ids.oldmapping";
35 private static final Map<String, String> newmap = new HashMap<String, String>();
36 static {
37 // Add known new mappings
38 newmap.put("EST", "EST");
39 newmap.put("MST", "MST");
40 newmap.put("HST", "HST");
41 }
42
43 public static void main(String[] args) {
44 boolean useOldMapping = true;
45 String arg = args[0];
46 if (arg.equals("-new")) {
47 useOldMapping = false;
48 } else if (arg.equals("-old")) {
49 useOldMapping = true;
50 } else {
51 throw new RuntimeException("-old or -new must be specified; got " + arg);
52 }
53
54 Map<String, String> oldmap = TzIDOldMapping.MAP;
55 String prop = System.getProperty(MAPPING_PROPERTY_NAME);
56 System.out.println(MAPPING_PROPERTY_NAME + "=" + prop);
57
58 // Try the test multiple times with modifying TimeZones to
59 // make sure TimeZone instances for the old mapping are
60 // properly copied (defensive copy).
61 for (int count = 0; count < 3; count++) {
62 for (String id : oldmap.keySet()) {
63 TimeZone tzAlias = TimeZone.getTimeZone(id);
64 TimeZone tz = TimeZone.getTimeZone(oldmap.get(id));
65 if (useOldMapping) {
66 if (!tzAlias.hasSameRules(tz)) {
67 throw new RuntimeException("OLDMAP: " + MAPPING_PROPERTY_NAME + "=" + prop + ": "
68 + id + " isn't an alias of " + oldmap.get(id));
69 }
70 if (count == 0) {
71 System.out.println(" " + id + " => " + oldmap.get(id));
72 }
73 tzAlias.setRawOffset(tzAlias.getRawOffset() * count);
74 } else {
|