Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
/ jdk16 Public archive

Commit

Permalink
8260927: StringBuilder::insert is incorrect without Compact Strings
Browse files Browse the repository at this point in the history
Reviewed-by: redestad, alanb, rriggs, jlaskey
  • Loading branch information
shipilev committed Feb 2, 2021
1 parent ed1a775 commit 081fa3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -3621,7 +3621,7 @@ void getBytes(byte[] dst, int dstBegin, byte coder) {
*/
void getBytes(byte[] dst, int srcPos, int dstBegin, byte coder, int length) {
if (coder() == coder) {
System.arraycopy(value, srcPos, dst, dstBegin << coder, length << coder());
System.arraycopy(value, srcPos << coder, dst, dstBegin << coder, length << coder);
} else { // this.coder == LATIN && coder == UTF16
StringLatin1.inflate(value, srcPos, dst, dstBegin, length);
}
Expand Down
3 changes: 2 additions & 1 deletion test/jdk/java/lang/StringBuilder/Insert.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

/**
* @test
* @run testng Insert
* @bug 4914802 8257511
* @summary Test StringBuilder.insert sanity tests
* @run testng/othervm -XX:-CompactStrings Insert
* @run testng/othervm -XX:+CompactStrings Insert
*/
@Test
public class Insert {
Expand Down

1 comment on commit 081fa3e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.