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

method readUTF throws unexpected EOFException

    XMLWordPrintable

    Details

      Description



      Name: ipR10067 Date: 09/28/2001



      Specification of the
      method javax.imageio.stream.ImageInputStreamImpl.readUTF says:

      "public String readUTF() throws IOException
       ...
          The current byte order setting is ignored.
       ...
      "

      The implementation (JDK 1.4.0beta3, build b80) of the method
      throws unexpected java.io.EOFException when the reverse byte order is set.

      To reproduce the bug run the following test:
      ------------ test.java ------------------------
      import java.io.IOException;
      import java.nio.ByteOrder;
      import java.io.ByteArrayOutputStream;
      import javax.imageio.stream.MemoryCacheImageOutputStream;

      public class test {
          
          public static void main(String argv[]) {
           
              ByteArrayOutputStream ostream = new ByteArrayOutputStream();
              MemoryCacheImageOutputStream iosI = new MemoryCacheImageOutputStream(ostream);

              char [] bufCharForUTF = { '\u0015', '\u0077', '\u0000', '\u0080', '\u0081',
                                        '\u00cd', '\u07fe', '\u07ff', '\u0800', '\u0801'};
              String s = new String(bufCharForUTF);
              String res;
             
              try {
                  iosI.writeUTF(s);
                  /* setting network byte order */
                  iosI.setByteOrder(ByteOrder.BIG_ENDIAN);
                  iosI.seek(0);
                  res = iosI.readUTF();
                  System.out.println("1. String " + res + " . OKAY");

                  /* setting reverse byte order */
                  iosI.setByteOrder(ByteOrder.LITTLE_ENDIAN);
                  iosI.seek(0);
                  res = iosI.readUTF();
                  System.out.println("2. String " + res + " . OKAY");

                  return;
          
              } catch (IOException e) {
                  System.out.println("Unexpected IOException: " + e);
                  return;
              }
          }
      }

      ------------ 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
      1. String w????. OKAY
      Unexpected IOException: java.io.EOFException

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

      This bug affects new JCK test:
      api/javax_imageio/stream/ImageOutputStreamImpl/index.html#WriteUTF[WriteUTF005]

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

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

      Name: ipR10067 Date: 09/30/2001



      Also this bug affects new JCK tests:
      api/javax_imageio/stream/ImageInputStreamImpl/index.html#ReadUTF[ReadUTF002]
      api/javax_imageio/stream/ImageInputStreamImpl/index.html#ReadUTF[ReadUTF003]

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              campbell Christopher Campbell (Inactive)
              Reporter:
              ipsunw Ip Ip (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: