-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta3
-
generic
-
generic
Name: ipR10067 Date: 08/21/2001
Method javax.imageio.stream.ImageInputStreamImpl.readUTF() does not work as specified.
This method is inherited by some classes of package javax.imageio.stream.
Specification of the class javax.imageio.stream.ImageInputStreamImpl says:
"public String readUTF() throws IOException
...
First, two bytes are read and used to construct an unsigned 16-bit
integer in the manner of the readUnsignedShort method,
using network byte order (regardless of the current byte order setting).
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
The current byte order setting is ignored.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"
However, the current implementation (JDK 1.4.0beta, build b77) of the method does
not ignore byte order setting.
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 len = 256;
char [] cc = new char[len];
for (int i = 0; i < len; i++) {
cc[i] = '\u0001';
}
String s = new String(cc);
String res1;
String res2;
// set network byte order
iosI.setByteOrder(true);
iosI.seek(0);
iosI.writeUTF(s);
iosI.seek(0);
res1 = iosI.readUTF();
// set reverse byte order
iosI.setByteOrder(false);
iosI.seek(0);
res2 = iosI.readUTF();
if ( res1.equals(res2)) {
System.out.println("OKAY");
} else {
System.out.println("Failed: res1.length() = " + res1.length()
+ " res2.length() = " + res2.length());
}
} catch (Exception e) {
System.out.println("Failed: unexpected exception " + e);
}
}
}
-----------------------------------------
% javac -d . test.java
% java -version
java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
% java test
Failed: res1.length() = 256 res2.length() = 1
JCK tests affected:
api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteUTF[WriteUTF005]
======================================================================
- duplicates
-
JDK-4508449 method readUTF throws unexpected EOFException
-
- Closed
-
- relates to
-
JDK-4462649 contradiction between writeUTF(String) and readUTF()
-
- Closed
-