java.io.IOException bug SOLVED!

Jake Hamby jehamby at lightside.com
Fri Jul 17 19:33:11 PDT 1998


On Fri, 17 Jul 1998, Jake Hamby wrote:

> Anyway, here's the patch.  I'm still having problems with the Bean,
> ReflectInvoke, and GCTest regression tests, but the others work now.
> Enjoy!

Oops, I just realized that my patch has a bug.  Instead of:

+         int cur = lseek(fd, 0, SEEK_SET);
+         nr = lseek(fd, 0, SEEK_END);
+         lseek(fd, cur, SEEK_SET); 
+	  return nr;

you need to:

	return nr - cur;

But I also thought of an optimization.  Since fstat() returns the file
size, you don't need the last two seeks at all.  Simply do this:

	int cur = lseek(fd, 0, SEEK_SET);
	return buf.st_size - cur;

I haven't tested either of these changes, and obviously it'd be a good
idea to use a better test program that reads some bytes from the file then
calls available() again.  Please let me know how it works out.

-Jake



More information about the kaffe mailing list