-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.0.2
-
sparc
-
solaris_2.5
Name: saC57035 Date: 12/01/96
The java.io.PushbackInputStream.unread(ch) method works wrong
with ch out of range 0..255.
It assigns ch to instance variable `pushBack' skipping "& 0xFF" operation.
Here is the example demonstrating the bug:
-----------------Test.java------------------------
import java.io.*;
public class Test {
public static void main( String argv[] ) {
byte[] data = {30};
int b1,b2;
PushbackInputStream in = new PushbackInputStream(new ByteArrayInputStream(data));
try {
in.unread(-1);
b = in.read();
System.out.println("The following bytes should be equal: "+(-1 & 0xFF)+" and "+b);
} catch (Throwable e) {
System.out.println("Unexpected "+e+" is thrown");
}
}
---------Output from the test---------------------
The following bytes should be equal: 255 and 30
--------------------------------------------------
======================================================================