diff --git a/src/java.base/share/classes/java/util/TimeZone.java b/src/java.base/share/classes/java/util/TimeZone.java index 1a91caf8df0da..9e80c4ae57dc5 100644 --- a/src/java.base/share/classes/java/util/TimeZone.java +++ b/src/java.base/share/classes/java/util/TimeZone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -593,15 +593,6 @@ private ZoneId toZoneId0() { // delegate to default TZ which is effectively immutable return defaultZone.toZoneId(); } - // derive it ourselves - if (ZoneInfoFile.useOldMapping() && id.length() == 3) { - if ("EST".equals(id)) - return ZoneId.of("America/New_York"); - if ("MST".equals(id)) - return ZoneId.of("America/Denver"); - if ("HST".equals(id)) - return ZoneId.of("America/Honolulu"); - } return ZoneId.of(id, ZoneId.SHORT_IDS); } diff --git a/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java b/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java index 4e30e403bb2f5..3f4c432d5f951 100644 --- a/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java +++ b/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java @@ -43,14 +43,12 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.SimpleTimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.zip.CRC32; import jdk.internal.util.StaticProperty; -import sun.security.action.GetPropertyAction; /** * Loads TZDB time-zone rules for j.u.TimeZone @@ -66,18 +64,10 @@ public final class ZoneInfoFile { */ public static String[] getZoneIds() { int len = regions.length + oldMappings.length; - if (!USE_OLDMAPPING) { - len += 3; // EST/HST/MST not in tzdb.dat - } String[] ids = Arrays.copyOf(regions, len); int i = regions.length; - if (!USE_OLDMAPPING) { - ids[i++] = "EST"; - ids[i++] = "HST"; - ids[i++] = "MST"; - } - for (int j = 0; j < oldMappings.length; j++) { - ids[i++] = oldMappings[j][0]; + for (String[] oldMapping : oldMappings) { + ids[i++] = oldMapping[0]; } return ids; } @@ -216,9 +206,6 @@ private ZoneInfoFile() { private static String[] regions; private static int[] indices; - // Flag for supporting JDK backward compatible IDs, such as "EST". - private static final boolean USE_OLDMAPPING; - private static final String[][] oldMappings = new String[][] { { "ACT", "Australia/Darwin" }, { "AET", "Australia/Sydney" }, @@ -233,10 +220,13 @@ private ZoneInfoFile() { { "CTT", "Asia/Shanghai" }, { "EAT", "Africa/Addis_Ababa" }, { "ECT", "Europe/Paris" }, + { "EST", "America/Panama" }, + { "HST", "Pacific/Honolulu" }, { "IET", "America/Indiana/Indianapolis" }, { "IST", "Asia/Kolkata" }, { "JST", "Asia/Tokyo" }, { "MIT", "Pacific/Apia" }, + { "MST", "America/Phoenix" }, { "NET", "Asia/Yerevan" }, { "NST", "Pacific/Auckland" }, { "PLT", "Asia/Karachi" }, @@ -248,10 +238,6 @@ private ZoneInfoFile() { }; static { - String oldmapping = GetPropertyAction - .privilegedGetProperty("sun.timezone.ids.oldmapping", "false") - .toLowerCase(Locale.ROOT); - USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true")); loadTZDB(); } @@ -274,25 +260,6 @@ public Void run() { }); } - private static void addOldMapping() { - for (String[] alias : oldMappings) { - aliases.put(alias[0], alias[1]); - } - if (USE_OLDMAPPING) { - aliases.put("EST", "America/New_York"); - aliases.put("MST", "America/Denver"); - aliases.put("HST", "Pacific/Honolulu"); - } else { - zones.put("EST", new ZoneInfo("EST", -18000000)); - zones.put("MST", new ZoneInfo("MST", -25200000)); - zones.put("HST", new ZoneInfo("HST", -36000000)); - } - } - - public static boolean useOldMapping() { - return USE_OLDMAPPING; - } - /** * Loads the rules from a DateInputStream * @@ -350,8 +317,6 @@ private static void load(DataInputStream dis) throws IOException { aliases.put(alias, region); } } - // old us time-zone names - addOldMapping(); } /////////////////////////Ser///////////////////////////////// diff --git a/test/jdk/java/util/TimeZone/OldIDMappingTest.java b/test/jdk/java/util/TimeZone/OldIDMappingTest.java deleted file mode 100644 index 8436080b0416f..0000000000000 --- a/test/jdk/java/util/TimeZone/OldIDMappingTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 6466476 - * @summary Compatibility test for the old JDK ID mapping and Olson IDs - * @comment Expecting the new (Olson compatible) mapping (default) - * @run main/othervm -Dsun.timezone.ids.oldmapping=null OldIDMappingTest -new - * @run main/othervm -Dsun.timezone.ids.oldmapping="" OldIDMappingTest -new - * @run main/othervm -Dsun.timezone.ids.oldmapping=no OldIDMappingTest -new - * @run main/othervm -Dsun.timezone.ids.oldmapping=No OldIDMappingTest -new - * @run main/othervm -Dsun.timezone.ids.oldmapping=NO OldIDMappingTest -new - * @run main/othervm -Dsun.timezone.ids.oldmapping=false OldIDMappingTest -new - * @run main/othervm -Dsun.timezone.ids.oldmapping=False OldIDMappingTest -new - * @run main/othervm -Dsun.timezone.ids.oldmapping=FALSE OldIDMappingTest -new - * @run main/othervm -Dsun.timezone.ids.oldmapping=Hello OldIDMappingTest -new - * @comment Expecting the old mapping - * @run main/othervm -Dsun.timezone.ids.oldmapping=true OldIDMappingTest -old - * @run main/othervm -Dsun.timezone.ids.oldmapping=True OldIDMappingTest -old - * @run main/othervm -Dsun.timezone.ids.oldmapping=TRUE OldIDMappingTest -old - * @run main/othervm -Dsun.timezone.ids.oldmapping=yes OldIDMappingTest -old - * @run main/othervm -Dsun.timezone.ids.oldmapping=Yes OldIDMappingTest -old - * @run main/othervm -Dsun.timezone.ids.oldmapping=YES OldIDMappingTest -old - */ - -import java.util.HashMap; -import java.util.Map; -import java.util.TimeZone; - -public class OldIDMappingTest { - private static final String MAPPING_PROPERTY_NAME = "sun.timezone.ids.oldmapping"; - private static final Map newmap = new HashMap(); - static { - // Add known new mappings - newmap.put("EST", "EST"); - newmap.put("MST", "MST"); - newmap.put("HST", "HST"); - } - - public static void main(String[] args) { - boolean useOldMapping = true; - String arg = args[0]; - if (arg.equals("-new")) { - useOldMapping = false; - } else if (arg.equals("-old")) { - useOldMapping = true; - } else { - throw new RuntimeException("-old or -new must be specified; got " + arg); - } - - Map oldmap = TzIDOldMapping.MAP; - String prop = System.getProperty(MAPPING_PROPERTY_NAME); - System.out.println(MAPPING_PROPERTY_NAME + "=" + prop); - - // Try the test multiple times with modifying TimeZones to - // make sure TimeZone instances for the old mapping are - // properly copied (defensive copy). - for (int count = 0; count < 3; count++) { - for (String id : oldmap.keySet()) { - TimeZone tzAlias = TimeZone.getTimeZone(id); - TimeZone tz = TimeZone.getTimeZone(oldmap.get(id)); - if (useOldMapping) { - if (!tzAlias.hasSameRules(tz)) { - throw new RuntimeException("OLDMAP: " + MAPPING_PROPERTY_NAME - + "=" + prop + ": " + id - + " isn't an alias of " + oldmap.get(id)); - } - if (count == 0) { - System.out.println(" " + id + " => " + oldmap.get(id)); - } - tzAlias.setRawOffset(tzAlias.getRawOffset() * count); - } else { - if (!newmap.containsKey(id)) { - // ignore ids not contained in the new map - if (count == 0) { - System.out.println(" " + id + " => " + oldmap.get(id)); - } - tzAlias.setRawOffset(tzAlias.getRawOffset() * count); - continue; - } - if (tzAlias.hasSameRules(tz)) { - throw new RuntimeException("NEWMAP: " + MAPPING_PROPERTY_NAME - + "=" + prop + ": " + id - + " is an alias of " + oldmap.get(id)); - } - tz = TimeZone.getTimeZone(newmap.get(id)); - if (!tzAlias.hasSameRules(tz)) { - throw new RuntimeException("NEWMAP: " + MAPPING_PROPERTY_NAME - + "=" + prop + ": " + id - + " isn't an alias of " + newmap.get(id)); - } - if (count == 0) { - System.out.println(" " + id + " => " + newmap.get(id)); - } - tzAlias.setRawOffset(tzAlias.getRawOffset() * count); - } - } - } - } -} diff --git a/test/jdk/java/util/TimeZone/TzIDOldMapping.java b/test/jdk/java/util/TimeZone/TzIDOldMapping.java deleted file mode 100644 index 7bfcf04854c89..0000000000000 --- a/test/jdk/java/util/TimeZone/TzIDOldMapping.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.util.Map; -import java.util.HashMap; - -class TzIDOldMapping { - static final Map MAP = new HashMap(); - static { - String[][] oldmap = { - { "ACT", "Australia/Darwin" }, - { "AET", "Australia/Sydney" }, - { "AGT", "America/Argentina/Buenos_Aires" }, - { "ART", "Africa/Cairo" }, - { "AST", "America/Anchorage" }, - { "BET", "America/Sao_Paulo" }, - { "BST", "Asia/Dhaka" }, - { "CAT", "Africa/Harare" }, - { "CNT", "America/St_Johns" }, - { "CST", "America/Chicago" }, - { "CTT", "Asia/Shanghai" }, - { "EAT", "Africa/Addis_Ababa" }, - { "ECT", "Europe/Paris" }, - { "EST", "America/New_York" }, - { "HST", "Pacific/Honolulu" }, - { "IET", "America/Indianapolis" }, - { "IST", "Asia/Calcutta" }, - { "JST", "Asia/Tokyo" }, - { "MIT", "Pacific/Apia" }, - { "MST", "America/Denver" }, - { "NET", "Asia/Yerevan" }, - { "NST", "Pacific/Auckland" }, - { "PLT", "Asia/Karachi" }, - { "PNT", "America/Phoenix" }, - { "PRT", "America/Puerto_Rico" }, - { "PST", "America/Los_Angeles" }, - { "SST", "Pacific/Guadalcanal" }, - { "VST", "Asia/Saigon" }, - }; - for (String[] pair : oldmap) { - MAP.put(pair[0], pair[1]); - } - } -} diff --git a/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java b/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java index 40f9cb9056cc9..077f17cf28424 100644 --- a/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java +++ b/test/jdk/sun/util/calendar/zi/ZoneInfoOld.java @@ -85,18 +85,6 @@ public class ZoneInfoOld extends TimeZone { 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 = System.getProperty("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(); /** @@ -653,18 +641,6 @@ public static String[] getAvailableIDs(int rawOffset) { 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; - } - } - ZoneInfoOld zi = ZoneInfoFile.getZoneInfoOld(ID); if (zi == null) { // if we can't create an object for the ID, try aliases. @@ -842,12 +818,6 @@ public synchronized static Map getAliasTable() { 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>(aliases); } }