-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
hopper
-
generic, x86
-
generic, linux
Name: ipR10067 Date: 09/27/2001
Specification of the
method javax.imageio.stream.ImageOutputStreamImpl.writeBits
says:
"public void writeBits(long bits, int numBits) throws IOException
... The bit offset is advanced by numBits and reduced modulo 8.
"
The implementation (JDK 1.4.0beta3, build b80) of the method
sets current bit offset to numBits instead of advancing by numBits.
To reproduce the bug run the following test:
------------ test.java ------------------------
import javax.imageio.stream.MemoryCacheImageOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class test {
public static void main(String argv[]) {
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
MemoryCacheImageOutputStream mcios = new MemoryCacheImageOutputStream(ostream);
try {
for (int i=0; i < 8; i+=2) {
mcios.writeBits(3, 2);
System.out.println(mcios.getBitOffset());
}
} catch (IOException e) {
System.out.println("Unexpected IOException: " + e);
}
}
}
------------ Logs -----------------------------
$ java -version
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b80)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b80, mixed mode)
$ javac -d . test.java
$ java test
2
2
2
2
======================================================================
This bug affects new JCK test:
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteBits[WriteBits001]
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteBits[WriteBits002]
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteBits[WriteBits003]
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteBits[WriteBits004]
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteBits[WriteBits005]
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteBits[WriteBits006]
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteBits[WriteBits007]
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteBits[WriteBits009]
======================================================================
======================================================================