RFR: 8291641: Optimize StackTraceElement.toString()

David Schlosnagle duke at openjdk.org
Mon Aug 1 17:31:53 UTC 2022


On Thu, 28 Jul 2022 13:12:57 GMT, Сергей Цыпанов <duke at openjdk.org> wrote:

>> `Appendable` does not currently have an `append(int)` method on the interface, though `StringBuilder` does. We could add it to `Appendable` via default method if so desired:
>> 
>> 
>> default Appendable append(int value) {
>>     return append(Integer.toString(value));
>> }
>
> I think in this case it's better to specify `StringBuilder` instead of `Appendable`, because the method is private and you'd hardly ever pass there anything different from SB.

If we go with the proposal above to make `appendTo(Appendable)` package visible so that `Throwable.printStackTrace()` can benefit from this as well, we would need to keep this as Appendable, otherwise I agree we should just inline this all into toString

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

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


More information about the core-libs-dev mailing list