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

method writeBit() throws IndexOutOfBoundsException after setBitOffset()

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta3
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: ipR10067 Date: 09/03/2001



      The method ImageOutputStreamImpl.writeBit() throws IndexOutOfBoundsException
      after setBitOffset() method invocation with non-zero bit offset.
      Whet bit offset is zero it works fine.

      To reproduce this bug run the following test:
      ---------------------test.java--------------
      import java.io.*;
      import javax.imageio.stream.*;

      public class test {
          public static void main(String[] argv) {

             ByteArrayOutputStream ostream = new ByteArrayOutputStream();

             MemoryCacheImageOutputStream iosI = new MemoryCacheImageOutputStream(ostream);

             try {
         /* work around
                  iosI.setBitOffset(0);
                  iosI.writeBit(0);
         */

                  iosI.setBitOffset(2);
                  iosI.writeBit(1);
                  System.out.println("third bit has been set successfully!");

              } catch (IOException e) {
                   System.out.println("Failed: unxepected Exception: " + e);
              }
         }
      }

      -----------------------------------------
      % javac test.java
      % java -version
      novo50% java -version
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b78)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b78, mixed mode)
      % java test
      Exception in thread "main" java.lang.IndexOutOfBoundsException: pos < flushedPos!
      at javax.imageio.stream.ImageInputStreamImpl.seek(ImageInputStreamImpl.java:732)
      at javax.imageio.stream.ImageOutputStreamImpl.writeBits(ImageOutputStreamImpl.java:389)
      at javax.imageio.stream.ImageOutputStreamImpl.writeBit(ImageOutputStreamImpl.java:372)
      at test.main(test.java:14)


      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dricesunw Daniel Rice (Inactive)
              Reporter:
              ipsunw Ip Ip (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: