diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index c1cece08069..d38c32b234e 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -765,8 +765,13 @@ void java_lang_String::print(oop java_string, outputStream* st) { st->print("\""); for (int index = 0; index < length; index++) { - st->print("%c", (!is_latin1) ? value->char_at(index) : - ((jchar) value->byte_at(index)) & 0xff ); + jchar c = (!is_latin1) ? value->char_at(index) : + ((jchar) value->byte_at(index)) & 0xff; + if (c < ' ') { + st->print("\\x%02X", c); // print control characters e.g. \x0A + } else { + st->print("%c", c); + } } st->print("\""); }