Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
naotoj committed Sep 19, 2024
1 parent 90e92f9 commit e8090bb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 265 deletions.
11 changes: 1 addition & 10 deletions src/java.base/share/classes/java/util/TimeZone.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
45 changes: 5 additions & 40 deletions src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -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" },
Expand All @@ -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" },
Expand All @@ -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();
}

Expand All @@ -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
*
Expand Down Expand Up @@ -350,8 +317,6 @@ private static void load(DataInputStream dis) throws IOException {
aliases.put(alias, region);
}
}
// old us time-zone names
addOldMapping();
}

/////////////////////////Ser/////////////////////////////////
Expand Down
121 changes: 0 additions & 121 deletions test/jdk/java/util/TimeZone/OldIDMappingTest.java

This file was deleted.

64 changes: 0 additions & 64 deletions test/jdk/java/util/TimeZone/TzIDOldMapping.java

This file was deleted.

30 changes: 0 additions & 30 deletions test/jdk/sun/util/calendar/zi/ZoneInfoOld.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -842,12 +818,6 @@ public synchronized static Map<String, String> 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<Map<String, String>>(aliases);
}
}
Expand Down

0 comments on commit e8090bb

Please sign in to comment.