forked from pool/java-1_8_0-openjdk
69 lines
2.8 KiB
Diff
69 lines
2.8 KiB
Diff
--- openjdk/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2017-07-27 02:47:51.000000000 +0200
|
|
+++ openjdk/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2017-09-28 17:44:23.511675990 +0200
|
|
@@ -31,6 +31,7 @@
|
|
import java.io.DataInputStream;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
+import java.io.InputStream;
|
|
import java.io.IOException;
|
|
import java.io.StreamCorruptedException;
|
|
import java.security.AccessController;
|
|
@@ -47,6 +48,7 @@
|
|
import java.util.Map;
|
|
import java.util.Map.Entry;
|
|
import java.util.Objects;
|
|
+import java.util.Properties;
|
|
import java.util.Set;
|
|
import java.util.SimpleTimeZone;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@@ -251,7 +253,17 @@
|
|
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
|
public Object run() {
|
|
try {
|
|
- String libDir = System.getProperty("java.home") + File.separator + "lib";
|
|
+ final String homeDir =
|
|
+ AccessController.doPrivileged(
|
|
+ new sun.security.action.GetPropertyAction("java.home"));
|
|
+ if (homeDir == null) {
|
|
+ throw new Error("java.home is not set");
|
|
+ }
|
|
+ String libDir = homeDir + File.separator + "lib";
|
|
+ String otherDir = getZoneInfoDir(libDir);
|
|
+ if (otherDir != null)
|
|
+ libDir = otherDir;
|
|
+
|
|
try (DataInputStream dis = new DataInputStream(
|
|
new BufferedInputStream(new FileInputStream(
|
|
new File(libDir, "tzdb.dat"))))) {
|
|
@@ -264,6 +276,30 @@
|
|
}
|
|
});
|
|
}
|
|
+
|
|
+ private static String getZoneInfoDir(final String libDir) {
|
|
+ return AccessController.doPrivileged (new PrivilegedAction<String>() {
|
|
+ public String run() {
|
|
+ try {
|
|
+ File f = new File(libDir + File.separator + "tz.properties");
|
|
+ InputStream in = new FileInputStream(f);
|
|
+ BufferedInputStream bin = new BufferedInputStream(in);
|
|
+ Properties props = new Properties();
|
|
+ props.load(bin);
|
|
+ bin.close();
|
|
+ String dir = props.getProperty("sun.zoneinfo.dir");
|
|
+ if (dir == null)
|
|
+ return null;
|
|
+ File tzdbdat = new File(dir, "tzdb.dat");
|
|
+ if (tzdbdat.exists())
|
|
+ return dir;
|
|
+ return null;
|
|
+ } catch (Exception x) {
|
|
+ return null;
|
|
+ }
|
|
+ }
|
|
+ });
|
|
+ }
|
|
|
|
private static void addOldMapping() {
|
|
for (String[] alias : oldMappings) {
|