mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8221430: StringBuffer(CharSequence) constructor truncates when -XX:-CompactStrings specified
Co-authored-by: Andrew Leonard <andrew_m_leonard@uk.ibm.com> Reviewed-by: igerasim, rriggs
This commit is contained in:
parent
758f02e6cc
commit
eebe346715
5 changed files with 83 additions and 19 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -42,6 +42,8 @@ public class StringBuilders {
|
|||
private String[] str16p8p7;
|
||||
private String[] str3p9p8;
|
||||
private String[] str22p40p31;
|
||||
private StringBuilder sbLatin1;
|
||||
private StringBuilder sbUtf16;
|
||||
|
||||
@Setup
|
||||
public void setup() {
|
||||
|
@ -53,6 +55,8 @@ public class StringBuilders {
|
|||
str16p8p7 = new String[]{"1234567890123456", "12345678", "1234567"};
|
||||
str3p9p8 = new String[]{"123", "123456789", "12345678"};
|
||||
str22p40p31 = new String[]{"1234567890123456789012", "1234567890123456789012345678901234567890", "1234567890123456789012345678901"};
|
||||
sbLatin1 = new StringBuilder("Latin1 string");
|
||||
sbUtf16 = new StringBuilder("UTF-\uFF11\uFF16 string");
|
||||
}
|
||||
|
||||
/** StringBuilder wins over StringMaker. */
|
||||
|
@ -256,4 +260,24 @@ public class StringBuilders {
|
|||
result.append("stringelinglinglinglong");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public StringBuilder fromLatin1String() {
|
||||
return new StringBuilder("Latin1 string");
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public StringBuilder fromUtf16String() {
|
||||
return new StringBuilder("UTF-\uFF11\uFF16 string");
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public StringBuilder fromLatin1StringBuilder() {
|
||||
return new StringBuilder(sbLatin1);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public StringBuilder fromUtf16StringBuilder() {
|
||||
return new StringBuilder(sbUtf16);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue