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

(spec) ByteArrayOutputStream does not adequately emphasize complex conversion to/from String

XMLWordPrintable

    • b89
    • generic
    • solaris_2.6

      The specification for ByteArrayOutputStream asserts that the "data can be
      retrieved using ... toString()." This is not true. You can't just "retrieve" a byte array into a string -- you have to somehow convert each 8-bit signed value into a 16-bit unsigned value.

      This assertion is almost true (and does little harm) when applied to the deprecated variant of toString(), which performs a simple, reversible padding on each byte. But the other variants transform each byte in complicated, locale-specific ways -- transformations that are often not reversible.

      Unfortunately many programmers assume that getString() *is* reversible. The result is a lot of code that is unintentionally locale-specific.

            jhangalsunw Jayalaxmi Hangal (Inactive)
            irabinovsunw Isaac Rabinovitch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: