JDK-8350042 : Release Note: Relax String Creation Requirements in StringBuilder and StringBuffer
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 25
  • Priority: P4
  • Status: Resolved
  • Resolution: Delivered
  • Submitted: 2025-02-13
  • Updated: 2025-03-13
  • Resolved: 2025-03-12
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 25
25Resolved
Description
The specifications of the `substring`, `subSequence`, and `toString` methods of the `StringBuilder` and `StringBuffer` classes have changed not to require a new `String` instance to be returned every time. This allows implementations to improve performance by returning an already-existing string, such as the empty string, when that is appropriate. In all cases, a `String` containing the expected value will be returned. However, applications should not depend on these methods to return a *new* `String` instance every time.