Skip to content

Commit

Permalink
8301065: Handle control characters in java_lang_String::print
Browse files Browse the repository at this point in the history
Reviewed-by: iklam, dholmes
  • Loading branch information
kevinjwalls committed Apr 24, 2023
1 parent 4b23bef commit 41d6be4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("\"");
}
Expand Down

3 comments on commit 41d6be4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 41d6be4 Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 41d6be4 Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-41d6be4d in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 41d6be4d from the openjdk/jdk repository.

The commit being backported was authored by Kevin Walls on 24 Apr 2023 and was reviewed by Ioi Lam and David Holmes.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-41d6be4d:GoeLin-backport-41d6be4d
$ git checkout GoeLin-backport-41d6be4d
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-41d6be4d

Please sign in to comment.