The remaining code sections that still build up strings manually using a chain of snprintf-like calls and manually counting the character offsets should be transformed to use stringStream instead.
For one, that code is difficult to read and maintain.
It is also error-prone: a common error would be to keep calling snprintf with the updated offset but the initial buffer length, which renders the snprintf truncation test void and risks overwriters.
Example (correct but cumbersome):
https://github.com/openjdk/jdk/blob/52155dbbb0107c5077a6be7edfd91d4311411fc3/src/hotspot/share/classfile/javaClasses.cpp#L2607-L2642
Note: in order to notice truncations with stringStream, we must also add a method to recognize truncation. As in `stringStream::did_truncate()`.
For one, that code is difficult to read and maintain.
It is also error-prone: a common error would be to keep calling snprintf with the updated offset but the initial buffer length, which renders the snprintf truncation test void and risks overwriters.
Example (correct but cumbersome):
https://github.com/openjdk/jdk/blob/52155dbbb0107c5077a6be7edfd91d4311411fc3/src/hotspot/share/classfile/javaClasses.cpp#L2607-L2642
Note: in order to notice truncations with stringStream, we must also add a method to recognize truncation. As in `stringStream::did_truncate()`.