TimeZone.java opens too many files?

Ito Kazumitsu ito.kazumitsu at hitachi-cable.co.jp
Wed Oct 11 21:58:08 PDT 2000


In my environment where
   OS = Linux 2.0.38 #2 Sun Jan 2 11:44:53 JST 2000,
   Kaffe = kaffe-1.0.6,
the following simple program does not run as expected.
It prints nothing.

$ cat TestTimeZone.java
import java.util.TimeZone;
import java.io.*;
public class TestTimeZone {
    public static void main(String[] args) {
       TimeZone tz = TimeZone.getDefault();
       System.out.println("timezone="+tz.getID());
       System.out.println("=========================");
    }
}
$ java TestTimeZone
$

After applying a patch for debugging to java/util/TimeZone.java,
the program shows "Too many open files".  What is the best way
to solve this problem?  Should I delete unnecessary files in
/usr/share/zoneinfo?  Well, I do not want to.

$ diff -u java/util/TimeZone.java.orig java/util/TimeZone.java
--- java/util/TimeZone.java.orig	Sat May 20 08:24:33 2000
+++ java/util/TimeZone.java	Thu Oct 12 13:31:56 2000
@@ -94,6 +94,7 @@
 // Recurse through a directory tree adding any UNIX zone files found
 private static void addZoneFiles(String prefix, File dir) {
 	String[] files = dir.list();
+	if (files == null) System.err.println(dir.getName()+" cannot be listed");
 	for (int i = 0; i < files.length; i++) {
 		File file = new File(dir, files[i]);
 		String filePrefix = (prefix == null) ?
@@ -103,6 +104,7 @@
 				zones.put(filePrefix,
 				    new UNIXTimeZone(filePrefix, file));
 			} catch (IOException e) {
+				System.err.println(file.getName()+":"+e);
 			}
 		} else if (file.isDirectory()) {
 			addZoneFiles(filePrefix, file);
$
$ CLASSPATH=. java TestTimeZone
leapseconds:java.io.IOException: invalid file contents
zone.tab:java.io.IOException: invalid file contents
South_Georgia:java.io.FileNotFoundException: /usr/share/zoneinfo/right/Atlantic/South_Georgia: Too many open files
Madeira:java.io.FileNotFoundException: /usr/share/zoneinfo/right/Atlantic/Madeira: Too many open files
Jan_Mayen:java.io.FileNotFoundException: /usr/share/zoneinfo/right/Atlantic/Jan_Mayen: Too many open files
Faeroe:java.io.FileNotFoundException: /usr/share/zoneinfo/right/Atlantic/Faeroe: Too many open files
Cape_Verde:java.io.FileNotFoundException: /usr/share/zoneinfo/right/Atlantic/Cape_Verde: Too many open files
Canary:java.io.FileNotFoundException: /usr/share/zoneinfo/right/Atlantic/Canary: Too many open files
Bermuda:java.io.FileNotFoundException: /usr/share/zoneinfo/right/Atlantic/Bermuda: Too many open files
Azores:java.io.FileNotFoundException: /usr/share/zoneinfo/right/Atlantic/Azores: Too many open files
Asia cannot be listed
java.lang.NullPointerException
        at java.util.TimeZone.addZoneFiles(TimeZone.java:98)
        at java.util.TimeZone.addZoneFiles(TimeZone.java:110)
        at java.util.TimeZone.addZoneFiles(TimeZone.java:110)
        at java.util.TimeZone.loadTimeZones(TimeZone.java:77)
        at java.util.TimeZone.getTimeZone(TimeZone.java:172)
        at java.util.TimeZone.getDefault(TimeZone.java:149)
        at TestTimeZone.main(TestTimeZone.java:5)
$


More information about the kaffe mailing list