JDK-6650179 : StringBuilder.toString() and StringBuffer.toString() optimization
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_9
  • CPU: generic,sparc
  • Submitted: 2008-01-14
  • Updated: 2010-05-11
  • Resolved: 2010-01-08
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
7Resolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
The optimization is to have the (JIT) compiler identify StringBuilder and StringBuffer usages where a StringBuilder or StringBuffer is allocated, things are appended to the StringBuilder or StringBuffer and StringBuilder.toString() or StringBuffer.toString() is called. Usages where the StringBuilder or StringBuffer does not escape or becomes dead, the char[] allocated by the StringBuilder or StringBuffer could be assigned to the String returned by the toString() method of StringBuilder or StringBuffer instead of allocating an additional char[] in a new String and copying the char's from the StringBuilder or StringBuffer's char[] to the String's newly allocated char[].

The end result is the saving of an unnecessary char[] allocation and a subsequent call to arraycopy.