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

FileChannel.write(ByteBuffer[]srcs,, int offset, int length) is broken

XMLWordPrintable

    • beta2
    • sparc
    • solaris_7
    • Verified

      This method is introduced in nio spec v 0.39.

      It throws NegativeArraySizeException when offset > length.

      This is inconsistent with spec.

      For example,
         // write out remaining bytes from srcBuffers[2] only
         fc.write(srcBuffers, 2, 1) ;

      ---------------------------
      java.lang.NegativeArraySizeException
              at sun.nio.ch.Util.subsequence(Util.java:22)
              at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:179)
              at FCgatheringWriteSubseq.writeGatheringTest02(FCgatheringWriteSubseq.java:254)
      ---------------------------

      Also, when offset < length it does not write out correct data from src
      Buffers to FileChannel.

      For example,
         // write out remaining bytes from srcBuffers[1] and srcBuffers[2]
         fc.write(srcBuffers, 1, 2) ;


      Merlin Build: 1.4.0-beta_refresh-b69

      Same results on Solaris 8, Windows NT, RedHat Linux 6.2.

            mmcclosksunw Michael Mccloskey (Inactive)
            hvilekar Harshad Vilekar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: