Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8256698

InputStream.skipNBytes could be implemented more efficiently

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 16
    • core-libs
    • None
    • behavioral
    • minimal
    • There is no risk as this is a performance enhancement and there is otherwise no change in behavior.
    • Java API
    • SE

      Summary

      Update the @implSpec verbiage of java.io.InputStream.skipNBytes() to match the implementation change to improve performance.

      Problem

      The implementation is improved to increase the method's performance and the @implSpec verbiage is no longer accurate.

      Solution

      Update the @implSpec verbiage to match the modified implementation.

      Specification

      Change the @implSpec verbiage of java.io.InputStream.skipNBytes() from

      If n is zero or negative, then no bytes are skipped. If n is positive, the default implementation of this method invokes skip() with parameter n. If the return value of skip(n) is non-negative and less than n, then read() is invoked repeatedly until the stream is n bytes beyond its position when this method was invoked or end of stream is reached. If the return value of skip(n) is negative or greater than n, then an IOException is thrown. Any exception thrown by skip() or read() will be propagated.

      to

      If n is zero or negative, then no bytes are skipped. If n is positive, the default implementation of this method invokes skip() repeatedly with its parameter equal to the remaining number of bytes to skip until the requested number of bytes has been skipped or an error condition occurs. If at any point the return value of skip() is negative or greater than the remaining number of bytes to be skipped, then an IOException is thrown. If skip() ever returns zero, then read() is invoked to read a single byte, and if it returns -1, then an EOFException is thrown. Any exception thrown by skip() or read() will be propagated.

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: