[Kaffe] java.io.File(Input|Output)Stream question.

Moses DeJong dejong at cs.umn.edu
Fri Feb 12 15:43:23 PST 1999


On Fri, 12 Feb 1999, Godmar Back wrote:

> > 
> > Ok, here is a quick shot at that.
> > 
> 
> This tests only one case, though.

The problem is that they throw a FileNotFoundException. The correct
thing to do in this case is to throw an IOException. Then in the case
where the file does not exist a FileNotFoundException can be thrown.
A FileNotFoundException is derived from IOException so there would
be no problem there. In the current JDK and Kaffe implementations
an IOException is rethrown as a FileNotFoundException which is
just plain wrong.


<SNIP from kaffe/libraries/javalib/java/io/FileInputStream.java

public FileInputStream(String name) throws FileNotFoundException {
	System.getSecurityManager().checkRead(name);		
	try {
		open(name);
	} catch (IOException e) {
		/* Note that open may throw an IOException, but the spec says 
		 * that this constructor throws only FileNotFoundExceptions, 
		 * hence we must map them.
		 */
		throw new FileNotFoundException(name + " " + e.getMessage());
	}
}

</SNIP>

mo dejong
dejong at cs.umn.edu

 
> So they say they throw FileNotFound, and they do indeed throw FileNotFound.
> So does Kaffe.  Where's the problem?
> 
> 	- Godmar
> 
> 



More information about the kaffe mailing list