[Top][All Lists]
[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
- Introduction and bug report,
Jeroen Frijters <=
- Re: Introduction and bug report, Mark Wielaard, 2002/07/11
- RE: Introduction and bug report, Jeroen Frijters, 2002/07/11
- RE: Introduction and bug report, Mark Wielaard, 2002/07/12
- Re: Introduction and bug report, Brian Jones, 2002/07/12
- Re: Introduction and bug report, Mark Wielaard, 2002/07/12
- Small javadoc patch for classpath., C. Scott Ananian, 2002/07/13
- Re: Small javadoc patch for classpath., Mark Wielaard, 2002/07/14