DigitList::toString method causing incorrect results during debugging
Chen Liang
chen.l.liang at oracle.com
Sat May 24 02:26:57 UTC 2025
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-retn at openjdk.org> on behalf of wenshao <shaojin.wensj at alibaba-inc.com>
Sent: Friday, May 23, 2025 8:00 PM
To: core-libs-dev <core-libs-dev at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250524/2f3b1d08/attachment.htm>
More information about the core-libs-dev
mailing list