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

(ch spec) Fencepost error in scatter/gather interfaces

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      In the arguments for java.nio.ScatteringByteChannel/GatheringByteChannel,
      there is a section in the offset:

      ---begin---
      long read(ByteBuffer[] dsts,
                int offset,
                int length)

          offset - The offset within the buffer array of the first buffer
      into which bytes are to be transferred; must be non-negative and no
      larger than dsts.length
          length - The maximum number of buffers to be accessed; must be
      non-negative and no larger than dsts.length - offset
      ---end---

      Let's ignore the length parameter for a second. Shouldn't offset be
      restricted to point to something that actually exists? If
      array.length = 4, do you really want to try to read from array[4]?
      This seems to be allowed by the spec. I read the spec's wording as
      0 <= offset <= array.length.

      I believe the offset description should read "dst.length - 1".

      This exists in both Scatter and Gather.

      ###@###.### 2004-03-24

        Attachments

          Activity

            People

            Assignee:
            sjiang Shanliang Jiang (Inactive)
            Reporter:
            wetmore Bradford Wetmore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: