RFR: JDK-8011136 - FileInputStream.available and skip inconsistencies

Dan Xu dan.xu at oracle.com
Fri May 10 21:20:40 UTC 2013


The FileInputStream.available() method can return a negative value when 
the file position is beyond the endof afile. This is an unspecified 
behaviour that has the potential to break applications that expect 
available to return a value of 0 or greater. The 
FileInputStream.skip(long) method allows a negative value as its 
parameter. This conflicts with the specifications of InputStream and 
FileInputStream classes.

They are both long standing behaviours. In the fix, available() has been 
changed to only return 0 or positive values. And for the skip(long) 
method, due to the compatibility concern, its behaviour will not be 
changed. Instead, the related java specs are going to be changed to 
describe its current behaviour.

bug: http://bugs.sun.com/view_bug.do?bug_id=8011136
webrev: http://cr.openjdk.java.net/~dxu/8011136/webrev.00/

Thanks for your review!


More information about the core-libs-dev mailing list