RFR: 8355636: Reuse StringBuilder in printStackTrace [v7]
Shaojin Wen
swen at openjdk.org
Mon Apr 28 07:52:54 UTC 2025
On Sat, 26 Apr 2025 22:42:08 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> In the Throwable::printStackTrace method, StringBuilder is created multiple times to build String. By sharing StringBuilder to build String, object allocation and copying are reduced.
>>
>> In the scenario without suppressed and ourCause, unused IdentityHashMap is not created.
>>
>> Through these optimizations, the performance of `new Exception().printStackTrace()` can be improved by about 10%.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>
> Update src/java.base/share/classes/java/lang/Throwable.java
>
> Co-authored-by: Hendrik Schick <30866028+ky0n at users.noreply.github.com>
Because more than one Reviewer disagrees with the changes in this PR, I have closed this PR. Thank you for the reviewers who spent time on this PR. Thank you for your time.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24864#issuecomment-2834284078
More information about the core-libs-dev
mailing list