I see. So we will need clarify the spec and make corresponding changes. I think as long as we don't trigger exceptions and just return 0 will be backward-compatible, right?

-Dan


On 03/30/2013 10:23 AM, Alan Bateman wrote:
On 26/03/2013 19:29, Dan Xu wrote:
Hi All,

In the old JVM function, os::available, it could return negative values because lseek() allows the file offset to be set beyond the end of a file. In the previous change of removing jvm functions, I wasn't aware of that and regardnegative values as invalid and return 0, which causes this test failed if it handles negative values. This fixaddressedthis problem and added a new testcase to ensure the correctbehaviour when available() encounters negative values.

Webrev: http://cr.openjdk.java.net/~dxu/8010837/webrev/

Thanks,

-Dan
I see this has already been pushed but I think it requires further discussion. I think it would be surprising if available() returned anything other than 0 for this case. You can't read a negative number of bytes, and with a normal InputStream then a negative skip is a no-op. So minimally we will need a spec clarification to make it clear how available() should behave when the file position is beyond the current file size. I just checked Channels.newInputStream and it does return 0 for this case. I also checked the FileInputStream.skip method and it seems to differ from its spec in that it allows a negative skip if the resulting file position is >= 0. I'll create bugs for these issues (assuming there aren't existing bugs on these topics area).

-Alan.

Reply via email to