RFR: 8291641: Optimize StackTraceElement.toString()

Сергей Цыпанов duke at openjdk.org
Mon Aug 1 17:31:56 UTC 2022


On Thu, 28 Jul 2022 14:38:50 GMT, Carter Kozak <duke at openjdk.org> wrote:

>> `Throwable.printStackTrace()` will use `StringBuilder` as well, won't it?
>
> I don't think so, it appends directly do something like System.err (default) or another PrintStream/PrintWriter without fully holding the string value on heap. If it supported overloads for Appendable/StringBuilder, that would be fantastic, but that would expand the scope of this PR. Is that something you would support?

I think we could create another PR adding suggested 

default Appendable append(int value) {
    return append(Integer.toString(value));
}

to `Appendable` if other JDK developers find it reasonable. Otherwise let's keep it as is.

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

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


More information about the core-libs-dev mailing list