RFR: 8301065: Handle control characters in java_lang_String::print
Kevin Walls
kevinw at openjdk.org
Wed Jan 25 12:46:37 UTC 2023
Change to avoid printing raw control characters in java_lang_String::print.
Usually called in debug printing and error reporting. One usage from debug logging for modules.
Format as \x followed by two hex digits, e.g. \x0A
Small change, in a routine with few callers. Could make two calls to value->byte_at(), which I left in as it reads more clearly, and this is not called at time critical situations.
The error reporting and debug.cpp usages I can test manually, with some trial and error, trying to catch the register info containing relevant info. This same String printing routine is used for showing register contents or stack slot mappings, and for a String, or a class containing a String.
Before the change: (newlines and null embedded in String)
R11=0x000000011f74e568 is an oop: java.lang.String
{0x000000011f74e568} - klass: 'java/lang/String'
- string: "this is my string
^@and also: this is more of my string
"
- ---- fields (total size 3 words):
- private 'hash' 'I' @12 0 (0x00000000)
With the change:
{0x000000011faf5bf0} - klass: 'Test'
- ---- fields (total size 3 words):
- private 'lastChar' 'C' @12 10 (0x000a)
- private 'myString' 'Ljava/lang/String;' @16 "this is my string\x0A\x00and also: this is more of my string\x0A"{0x000000011faf5ca8} (0x23f5eb95)
R15=0x00007f928002a260 is a thread
-------------
Commit messages:
- 8301065: Handle control characters in java_lang_String::print
Changes: https://git.openjdk.org/jdk/pull/12190/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12190&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8301065
Stats: 7 lines in 1 file changed: 5 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/12190.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12190/head:pull/12190
PR: https://git.openjdk.org/jdk/pull/12190
More information about the hotspot-runtime-dev
mailing list