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

(spec) java.io.DataInputStream.readUTF() is wrong about encoding name

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 1.4.2
    • 1.3.0
    • core-libs
    • None
    • mantis
    • generic
    • generic
    • Verified

      The documentation states that readUTF can throw a UTFDataFormatException if the input stream contains invalid UTF-8. However, the input stream for a String does not ever contain UTF-8. Instead, the readUTF reads a serialized String, for which the encoding is irrelevant, but is actually a modified UTF-8.

      This is an important distinction between UTF-8 and a "modified" UTF-8 because standard UTF-8 tools will not correctly interpret the "modified" UTF-8 used for String values. Developers may accidentally believe that Strings can be stored as UTF-8, when in fact they cannot.

            iris Iris Clark
            joconnersunw John Oconner (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: