Skip to content
Permalink
Browse files
8260927: StringBuilder::insert is incorrect without Compact Strings
Reviewed-by: redestad, alanb, rriggs, jlaskey
  • Loading branch information
shipilev committed Feb 2, 2021
1 parent ed1a775 commit 081fa3e7154db433b10b940ff223fd3d50099521
Showing with 3 additions and 2 deletions.
  1. +1 −1 src/java.base/share/classes/java/lang/String.java
  2. +2 −1 test/jdk/java/lang/StringBuilder/Insert.java
@@ -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);
}
@@ -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 {

0 comments on commit 081fa3e

Please sign in to comment.