Masayoshi Okutsu wrote:
Sorry for taking time to respond.

Likewise!

I've filed an RFE for this request to make sure Sun's JRE supports the same mechanism. Sun's Change Request ID (aka bug ID) is 6593486.

I'll add my comments/patch there, too, but I wanted to briefly let you know what I've been up to with all of this.

    * I think the "java." name space should be avoided for this purpose.
      "user.timezone.dir" should be OK.

Done.

    * I'd also suggest that "/usr/share/zoneinfo/java" be changed to
      something like "/usr/share/javazi" because Java runtime may search
      files under /usr/share/zoneinfo to detect the platform time zone
      setting. It costs extra to skip all the files under
      /usr/share/zoneinfo/java if the directory comes before other
      directories in /usr/share/zoneinfo. Also I think
      /usr/share/zoneinfo should contain the native Olson time zone data
      files only.

Done.

    * I'm not sure if the current implementation is robust enough to be
      able to reject all broken data files. It does check magic numbers,
      though. You may need extra tests with random directory paths. Or
      you could add more checking to see if the directory is right, such
      as existence of the ZoneInfoMappings file.

I've added a little something so that the code will check for a ZoneInfoMappings file before using the user.timezone.dir property. Beyond this, there seems little reason to do any more extreme error checking. The default is still to use the supplied, built-in tzdata. If the user sets user.timezone.dir to something else, he should be aware of what he is doing!

Thank you for your feedback,
Keith
--- openjdk.keiths/hotspot/src/os/linux/vm/os_linux.cpp	2007-08-30 00:16:05.000000000 -0700
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp	2007-09-06 16:56:18.000000000 -0700
@@ -376,6 +376,10 @@ void os::init_system_properties_values()
     }
   }
 
+  // Use the system zoneinfo files, if present
+  SystemProperty* sp = Arguments::system_properties();
+  Arguments::PropertyList_add (&sp,
+			       "user.zoneinfo.dir", "/usr/share/javazi");
 #undef malloc
 #undef getenv
 #undef EXTENSIONS_DIR
--- openjdk.keiths/j2se/src/share/classes/sun/util/calendar/ZoneInfoFile.java	2007-08-30 00:55:53.000000000 -0700
+++ openjdk/j2se/src/share/classes/sun/util/calendar/ZoneInfoFile.java	2007-09-10 11:49:41.000000000 -0700
@@ -1021,10 +1021,24 @@ public class ZoneInfoFile {
 	byte[] buffer = null;
 
 	try {
-	    String homeDir = (String) AccessController.doPrivileged(
-				new sun.security.action.GetPropertyAction("java.home"));
-	    final String fname = homeDir + File.separator + "lib" + File.separator
-				 + "zi" + File.separator + fileName;
+	    String zi_dir = (String) System.getProperty("user.zoneinfo.dir");
+	    File dir = null;
+	    if (zi_dir != null)
+	      dir = new File(zi_dir);
+
+	    // Some minimal sanity checking
+	    if (dir != null) {
+	      File f = new File(dir, "ZoneInfoMappings");
+	      if (!f.exists())
+		dir = null;
+	    }
+
+	    if (dir == null) {
+	      String homeDir = (String) System.getProperty("java.home");
+	      zi_dir = homeDir + File.separator + "lib" + File.separator
+		+ "zi";
+	    }
+	    final String fname =  zi_dir + File.separator + fileName;
 	    buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() {
 		public Object run() throws IOException {
 		    File file = new File(fname);

Reply via email to