JDK-8046201 : Avoid repeated flattening of nested ConsStrings
  • Type: Enhancement
  • Component: core-libs
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-06-06
  • Updated: 2015-01-21
  • Resolved: 2014-06-23
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 8 JDK 9
8u40Fixed 9 b22Fixed
Description
Currently, when a ConsString is flattened to a java.lang.String, only the top level string is generated and cached (for obvious reasons). However, if a ConsString is repeatedly concatenated with another string and then flattened we may want to generate and cache the java.lang.String representation of that partial ConsString. 

A typical use case is the following piece of code where `data` may be a constant, long ConsString.

    String(header + CRLF + data);