JDK 9 RFR of JDK-8136738: InputStream documentation for IOException in skip() is unclear or incorrect

Roger Riggs Roger.Riggs at Oracle.com
Fri Jun 3 19:20:51 UTC 2016


+1


On 6/3/2016 3:15 PM, Brian Burkhalter wrote:
> So if I make this change to the webrev
>
> --- a/src/java.base/share/classes/java/io/InputStream.java
> +++ b/src/java.base/share/classes/java/io/InputStream.java
> @@ -333,8 +333,7 @@
>       *
>       * @param     n   the number of bytes to be skipped.
>       * @return     the actual number of bytes skipped.
> -     * @throws     IOException  if an I/O error occurs, such as 
> attempting to
> -     *     seek to a negative position in a seek-based implementation.
> +     * @throws     IOException  if an I/O error occurs.
>       */
>      public long skip(long n) throws IOException {
>
> do we have consensus?
>
> Thanks,
>
> Brian
>
> On Jun 3, 2016, at 11:34 AM, Pavel Rappo <pavel.rappo at oracle.com 
> <mailto:pavel.rappo at oracle.com>> wrote:
>
>>
>>> On 3 Jun 2016, at 19:30, Bernd Eckenfels <ecki at zusammenkunft.net 
>>> <mailto:ecki at zusammenkunft.net>> wrote:
>>>
>>> It is unclear to me if this is really forbidden in the interface or in
>>> any implementation. With FileInputStream skip(-5) works.
>>
>> Don't mistake `seek` for `skip`. `skip` can be implemented using 
>> `read`, but
>> may be using `seek`.
>>
>> Here's the API point of view:
>>
>>    * If {@code n} is
>>    * negative, the {@code skip} method for class {@code InputStream} 
>> always
>>    * returns 0, and no bytes are skipped. Subclasses may handle the 
>> negative
>>    * value differently.
>>
>> Thanks,
>> -Pavel
>>
>>
>



More information about the core-libs-dev mailing list