Integrated: 8351443: Improve robustness of StringBuilder

Roger Riggs rriggs at openjdk.org
Fri May 9 21:50:58 UTC 2025


On Wed, 30 Apr 2025 14:12:36 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Refactor AbstractStringBuilder to maintain consistency among count, coder, and value buffers while the buffer capacity is being expanded and/or inflated from Latin1 to UTF16 representations. 
> The refactoring pattern is to read and write AbstractStringBuilder fields once using locals for all intermediate values. 
> Support methods are static, designed to pass all values as arguments and return a value.
> 
> The value byte array is reallocated under 3 conditions:
> - Increasing the capacity with the same encoder
> - Increasing the capacity and inflation to change the coder from LATIN1 to UTF16
> - Inflation with the same capacity
> 
> Added StressSBTest to exercise public instance methods of StringBuilder.

This pull request has now been integrated.

Changeset: 8fadf295
Author:    Roger Riggs <rriggs at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/8fadf295b0ba720a5bc728c6b4d159e60447de97
Stats:     1010 lines in 8 files changed: 733 ins; 68 del; 209 mod

8351443: Improve robustness of StringBuilder

Reviewed-by: liach, rgiulietti, bchristi, jpai

-------------

PR: https://git.openjdk.org/jdk/pull/24967


More information about the core-libs-dev mailing list