RFR: 8364103: Convert existing sprintf-chains to stringStream
Kim Barrett
kbarrett at openjdk.org
Sun Aug 24 13:01:52 UTC 2025
On Fri, 22 Aug 2025 08:49:56 GMT, Paul Hübner <duke at openjdk.org> wrote:
> Hi all,
>
> This PR refactors `javaClasses`' `print_stack_element_to_stream` to use a `stringStream` instead of manually maintaining a buffer with `os::snprintf` chains.
>
> The JBS issue outlines to do this for all occurrences of `snprintf`-like chains. The majority of the calls to `os::snprintf`, `os::snprintf_checked`, `os::vsnprintf`, etc. occur just once. `LogTagSet::vwrite` is the only place to my knowledge where there remains a `vsnprintf` chain using manual buffer arithmetic. After consulting @jdksjolen, we decided that due to the
> a) low-level nature of the code, and
> b) widespread usage of logging in the VM,
> this should probably warrant a larger discussion and/or separate issue. Personally, I feel like the performance & correctness risks of introducing a high-level abstraction here outweighs the benefits.
>
> I've run tests with JDK tiers 1-3 on macOS (AArch64, x64), Linux (AArch64, x64), and Windows (x64); all green.
src/hotspot/share/classfile/javaClasses.cpp line 2621:
> 2619: if (module_name != nullptr) {
> 2620: if (module_version != nullptr) {
> 2621: ss.print("%s@%s/", module_name, module_version);
Here and other places, this change is going to merge-conflict with https://github.com/openjdk/jdk/pull/26849.
I think that PR should be allowed to go first.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26894#discussion_r2296651803
More information about the hotspot-runtime-dev
mailing list