classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Introduction and bug report


From: Jeroen Frijters
Subject: Introduction and bug report
Date: Mon, 8 Jul 2002 09:47:30 +0200

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]