A DESCRIPTION OF THE REQUEST :
Consider the example code. StringBuilder is not going to escape. A String is going to be created at the end. We can eliminate a memory allocation and buffer copy by simply having the String object reference the char[] in StringBuilder. Since the StringBuilder can't be used any more, the optimized code can simply have String reference the char[] in StringBuilder.
JUSTIFICATION :
Consider the example code. StringBuilder is not going to escape. A String is going to be created at the end. We can eliminate a memory allocation and buffer copy by simply having the String object reference the char[] in StringBuilder.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The char[] referenced in StringBuilder be passed to String.
ACTUAL -
A separate char[] is created for String and populated with the contents of StringBuilder's char[].
---------- BEGIN SOURCE ----------
StringBuilder result;
result = new StringBuilder();
result.append("hello");
...
return(result.toString());
---------- END SOURCE ----------