6516099: InputStream.skipFully(int k) to skip exactly k bytes

Brent Christian brent.christian at oracle.com
Fri Nov 9 03:01:11 UTC 2018

On 11/8/18 12:52 PM, Brian Burkhalter wrote:
> Hi Daniel,
>> On Nov 8, 2018, at 1:50 AM, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:
>> So FWIW my point was that there's nothing that you can really
>> guarantee in InputSteam::skipFully() if a subclass implementation of
>> skip() uses negative number to e.g. signal abnormal conditions
>> (such as EOF?). And I wonder if that should warrant a disclaimer
>> in the API doc of InputStream::skipFully (maybe an @implSpec?)
> I don’t know about having an explicit disclaimer; that seems a little strange to me. If the new method is defined in terms of skip() the I would think that it is implicit that misbehavior of the latter would cause problems.

My thinking is along the lines of Daniel's.

skipNBytes() should account for weird behavior on the part of a 
subclass's skip() method.  I'm also in favor of documenting which other 
InputStream methods might be called.

But some of the possible skip() behavior being described is not 
mentioned in InputStream, such as skipping MORE than n bytes, or calling 
skip() with negative values in order to navigate backwards.

Some sort of disclaimer could frame the behavior being described, even 
if only something like, "skip() makes a best effort to account for a 
subclass's overridden skip() method behaving unexpectedly"


More information about the core-libs-dev mailing list