Thanks for this report. This code is indeed very old - and probably back then, people thought sharing StringBuffer (which has since been migrated to StringBuilder) was a great idea. I checked the use site of the temp buffer - it appears to me that in the lifecycle of a DigitList, that buffer is usually only created and used once, and the cache would actually be more of a penalty than an optimization if that is the case. In addition, I don't find any usage of toString of DigitList. I think it should be fine to create a PR to end the sharing of these temp buffer - a patch that uses a new StringBuilder for DigitList.toString should be the safest, before I18N engineers can determine if we can remove the cache mechanism altogether.
Chen ________________________________ From: core-libs-dev <core-libs-dev-r...@openjdk.org> on behalf of wenshao <shaojin.we...@alibaba-inc.com> Sent: Friday, May 23, 2025 8:00 PM To: core-libs-dev <core-libs-dev@openjdk.org> Subject: DigitList::toString method causing incorrect results during debugging When debugging getLong/getDouble/getDecimal of java.text.DigitList, the debugger will call the DigitList::toString method. At this time, DigitList::toString will modify tempBuilder, which will cause incorrect results. - Shaojin Wen