Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4018978

No file descriptors --> java.lang.NoClassDefFoundError when out of file descript

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1
    • core-libs
    • None
    • generic
    • solaris_2.5

      When too many FileInputStreams are created, runtime aborts with the
      message "java.lang.NoClassDefFoundError". (Incidentally, since File.close()
      is called from File.finalize(), IMHO it would be a Good Thing to have
      File's constructor do a GC before giving up if there aren't enough file
      descriptors, but that's tangential to this bug).

      This bug can be triggerd by the following code:

      public class foo {
       
          public static void main(String args[]) {
              try {
                  for (int i = 0; i < 1000; i++) {
                      java.io.FileInputStream s
                              = new java.io.FileInputStream("/etc/passwd");
                  }
              } catch (Exception ex) {
                  System.out.println(ex);
              }
              System.out.println("Normal exit");
          }
      }

      Running it produces:
          (env.n) billf@jovial:~/tmp$ java foo
          java.lang.NoClassDefFoundError

            mr Mark Reinhold
            bfootesunw Bill Foote (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: