-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
-
Not verified
Name: vpR10011 Date: 05/22/2001
Specification of the class javax.imageio.stream.ImageOutputStreamImpl says:
"public void writeBits(long bits, int numBits) throws IOException
...
The bit offset is advanced by numBits.
...".
But the bit offset is advanced by numBits and reduced modulo 8.
It might be misprint in this specification, because the bit offset is
an integer between 0 and 7, inclusive.
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) {
OutputStream os = (OutputStream) new ByteArrayOutputStream();
MemoryCacheImageOutputStream iosI =
new MemoryCacheImageOutputStream(os);
try {
int bitOff1 = iosI.getBitOffset();
iosI.writeBits(1L, 15);
int bitOff2 = iosI.getBitOffset();
if (bitOff2 == (bitOff1 + 15)) {
System.out.println("Passed");
} else {
System.out.println("Failed: getBitOffset() = " + bitOff2 + " expected "
+ (bitOff1 + 15));
}
} catch (Exception e) {
System.out.println("Failed: unexpected exception " + e);
}
}
}
-----------------------------------------
% javac -d . test.java
% java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
% java test
Failed: getBitOffset() = 7 expected 15
----------------------------------------
======================================================================