Hello everyone,

I'm building a JVM for .NET (see http://radio.weblogs.com/0109845/) and
I'm using classpath (the Java part, not the native code) as the Java
class library. So far it's going great, and I'd like to thank everyone
that contributed!

I've run into a small bug ;-) When you run the following program (on my
VM anyway):

import java.io.*;

class cpbug {
  pubblic static void main(String[] args) throws Exception {
    try { new FileInputStream("nonexisting"); } catch(IOException x) {}
    System.gc();
    System.in.read();
  }
}

The "System.in.read()" fails because the stdin stream has been closed!
This is due to a bug in FileInputStream. The native_fd in
FileInputStream is not initialized when there is an exception in the
constructor (such as the FileNotFoundException in this example), so it
will be 0. Now when the finalizer runs, it closes native_fd (0), which
results in stdin being closed.

The fix is easy:
  private int native_fd = -1;

The same thing also applies to FileOutputStream.

Regards,
Jeroen


_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to