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

jcmd can fail converting UTF8 output to strings

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 13
    • 11, 12
    • core-svc
    • b17

    Description

      In the jcmd execute() method, the bytes received from the VM are read into a 256 byte array and then converted to a String via:
        String s = new String(b, 0, n, "UTF-8");
      Since UTF-8 can have characters spanning multiple bytes, the last character might not be fully in the byte array, so it will not be printed. In addition we start with an invalid character in the next iteration of the loop.

      It is better to use a InputStreamReader, which handles all the intricacies of this scenario.

      Attachments

        Issue Links

          Activity

            People

              rschmelter Ralf Schmelter
              rschmelter Ralf Schmelter
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: