RFR: 8355301: Simplify Throwable::printStackTrace by using record [v4]

Shaojin Wen swen at openjdk.org
Fri Apr 25 01:24:44 UTC 2025


On Fri, 25 Apr 2025 00:53:35 GMT, Chen Liang <liach at openjdk.org> wrote:

>> To what end?
>> 
>> - "I was reading Throwable and noticed this possible refactoring."
>> - "I've run an analysis of the JDK code base and this is the first of N patches to move to using private records."
>> - "With this change, metric X is Y% better."
>> 
>> Something else?
>
> I think the initial version tried to use record and interfaces to simplify declarations; then I suggested that we have 3 classes, but we can just use an on-site instanceof check to reduce number of classes (which will be individual files in images, also class loading penalty for stack trace printing). However, Alan has this comment, which I don't understand quite well either - seems Alan was looking at an older revision as the interface was removed at the time of his comment.

I was reading `Throwable` source code and saw this and thought we could use the new language feature `record`. We should use more new language features in the core library, and this will be used as a reference.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24795#discussion_r2059430988


More information about the core-libs-dev mailing list