JDK-8148936 : Adapt UUID.toString() to Compact Strings
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-02-03
  • Updated: 2016-08-24
  • Resolved: 2016-02-04
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 9
9 b105Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
JDK-8006627 did the JavaLangAccess hack to improve UUID.toString() performance:

    public String toString() {
        char[] chars = new char[36];
        jla.formatUnsignedLong(mostSigBits >> 32, 4, chars, 0, 8);
        chars[8] = '-';
        jla.formatUnsignedLong(mostSigBits >> 16, 4, chars, 9, 4);
        chars[13] = '-';
        jla.formatUnsignedLong(mostSigBits, 4, chars, 14, 4);
        chars[18] = '-';
        jla.formatUnsignedLong(leastSigBits >> 48, 4, chars, 19, 4);
        chars[23] = '-';
        jla.formatUnsignedLong(leastSigBits, 4, chars, 24, 12);
        return jla.newStringUnsafe(chars);
    }

This is a good performance improvement, but it clashes with Compact Strings which now have to re-compress the resulting char[] array into byte[]. And we know that UUID would always produce Latin1 String.

If we follow the same route, and drill more holes in JavaLangAccess to accept Strings with a preset coder, we will also have to take care of the case when Compact Strings are turned off. It might turn beneficial to wait for JDK-8148604 to land, and revert toString() back to plain Java concatenation, letting advanced concat strategies to take care of optimal concat, even in the presence of unsigned long conversions.
Comments
RFR: http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-February/038596.html
03-02-2016