RFR: 8364103: Convert existing sprintf-chains to stringStream [v4]
Paul Hübner
phubner at openjdk.org
Mon Sep 8 09:47:56 UTC 2025
> 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.
Paul Hübner has updated the pull request incrementally with one additional commit since the last revision:
Update src/hotspot/share/classfile/javaClasses.cpp
Co-authored-by: David Holmes <62092539+dholmes-ora at users.noreply.github.com>
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/26894/files
- new: https://git.openjdk.org/jdk/pull/26894/files/3a87b884..21049190
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=26894&range=03
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=26894&range=02-03
Stats: 4 lines in 1 file changed: 0 ins; 3 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/26894.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26894/head:pull/26894
PR: https://git.openjdk.org/jdk/pull/26894
More information about the hotspot-runtime-dev
mailing list