The specs for various constructors of StringBuffer/StringBuilder contain text like
"The initial capacity of the string buffer is 16 plus the length of the string argument."
From a specification perspective, this leaves open the possibility of misbehavior near Integer.MAX_VALUE.
The spec in question would be improved by covering this situation explicitly, say by having the capacity saturate at MAX_VALUE.
"The initial capacity of the string buffer is 16 plus the length of the string argument."
From a specification perspective, this leaves open the possibility of misbehavior near Integer.MAX_VALUE.
The spec in question would be improved by covering this situation explicitly, say by having the capacity saturate at MAX_VALUE.
- relates to
-
JDK-8149330 Capacity of StringBuilder should not get close to Integer.MAX_VALUE unless necessary
- Resolved
-
JDK-8218227 StringBuilder/StringBuffer constructor throws confusing NegativeArraySizeException
- Resolved
-
JDK-8219196 DataOutputStream.writeUTF may throw unexpected exceptions
- Resolved
-
JDK-8218228 The constructor StringBuffer(CharSequence) violates spec for negatively sized argument
- Closed