JDK-8015604 : JDP packets containing ideographic characters are broken
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 7u40
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2013-05-29
  • Updated: 2013-12-17
  • Resolved: 2013-06-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u40 b30Fixed 8Fixed
Description
JDP packets with multibyte characters are broken since the code in JdpPacketWriter looks at the String length when adding entries instead of encoding the byte length. I.e. the code looks like this:

    public void addEntry(String entry)
            throws IOException {
        pkt.writeShort(entry.length());
        byte[] b = entry.getBytes("UTF-8");
        pkt.write(b);
    }

It should look like this:
    public void addEntry(String entry)
            throws IOException {
        byte[] b = entry.getBytes("UTF-8");
        pkt.writeShort(b.length);
        pkt.write(b);
    }

Or even more elegantly just like this:
    public void addEntry(String entry)
            throws IOException {
        pkt.writeUTF(entry);
    }
...as it seems that writeUTF in DataOutputStream actually encodes the length in a short in the beginning of the array. 

(This last version is how the JDPServer we use for testing in JMC is coded.)