-
Bug
-
Resolution: Fixed
-
P4
-
21, 22, 23
-
b11
-
generic
-
generic
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8327770 | 22.0.2 | Aleksey Shipilev | P4 | Resolved | Fixed | b01 |
JDK-8331299 | 21.0.7-oracle | Johny Jose | P4 | Open | Unresolved |
In Java 17 StringBuilder.toString was calling StringLatin1.newString that returned a literal "" for len == 0. After https://bugs.openjdk.org/browse/JDK-8282429 https://github.com/openjdk/jdk/commit/bab431cc120fe09be371dadef0c1caf79ec9eef4 Java 21 returns a new String object each time. While it is minor, it still looks like a regression that effects such code paths as deserialisation.
REGRESSION : Last worked in version 17.0.10
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
new StringBuilder().toString() == ""
ACTUAL -
false
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
System.out.println(new StringBuilder().toString() == "");
}
}
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8331299 StringBuilder.toString allocation for the empty String
- Open
-
JDK-8327770 StringBuilder.toString allocation for the empty String
- Resolved
- relates to
-
JDK-8240094 Optimize empty substring handling
- Resolved
-
JDK-8282429 StringBuilder/StringBuffer.toString() skip compressing for UTF16 strings
- Resolved
-
JDK-8332282 AbstractStringBuilder.toString spec needs amendments for empty strings
- New
- links to
-
Commit openjdk/jdk22u/b2275aac
-
Commit openjdk/jdk/d2590c69
-
Review openjdk/jdk21u-dev/364
-
Review openjdk/jdk22u/70
-
Review openjdk/jdk/17931