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

writeBit(int) does not pad the remainder of the current byte with 0s

    XMLWordPrintable

    Details

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

      Description



      Name: ipR10067 Date: 08/22/2001



      The specification for the method
      javax.imageio.stream.ImageOutputStreamImpl.writeBit reads:

      "public void writeBit(int bit) throws IOException
      ...
      If any bits of a particular byte have never been set
      at the time the byte is flushed to the destination,
      those bits will be set to 0 automatically.
      "

      But it does not work as expected:
      ===================== test.java =======================
      import java.io.*;
      import javax.imageio.stream.FileCacheImageOutputStream;

      public class test {
          public static void main (String argv[]) throws Exception {
              OutputStream ostream = new ByteArrayOutputStream();
              File f = null;
              FileCacheImageOutputStream fcios = new FileCacheImageOutputStream(ostream, f);

              fcios.writeBit(1);

              fcios.seek(0);

              int r1 = fcios.read();
              if( r1 != 128 ) {
                  System.out.println("Failed: " + r1 + "(should be 128)");
                  return;
              }

              System.out.println("Passed");
          }
      }

      ===================== log =======================
      %java -version
      java version "1.4.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)
      % javac -d . test.java
      % java test
      Failed: 255(should be 128)
       
      The same problem exists for the method writeBits.

      This bug affects new JCK tests:
      api/javax_imageio/stream/FileCacheImageOutputStream/index.html#seek[seek002]
      api/javax_imageio/stream/FileCacheImageOutputStream/index.html#write[write0021]
      api/javax_imageio/stream/FileCacheImageOutputStream/index.html#write[write002]
      api/javax_imageio/stream/FileImageOutputStream/index.html#seek[seek002]
      api/javax_imageio/stream/MemoryCacheImageOutputStream/index.html#seek[seek002]
      api/javax_imageio/stream/MemoryCacheImageOutputStream/index.html#write[write0021]
      api/javax_imageio/stream/MemoryCacheImageOutputStream/index.html#write[write002]

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

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

        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: