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

java.io.PushbackInputStream.unread(ch) method works wrong

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      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
      --------------------------------------------------

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

        Attachments

          Activity

            People

            Assignee:
            mr Mark Reinhold
            Reporter:
            savzan Stanislav Avzan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: