RFR 8218228 : The constructor StringBuffer(CharSequence) violates spec for negatively sized argument
Ivan Gerasimov
ivan.gerasimov at oracle.com
Fri Feb 8 01:02:30 UTC 2019
Hello!
The specification states:
"""
If the length of the specified CharSequence is less than or equal to
zero, then an empty buffer of capacity 16 is returned.
"""
However, the current implementation throws either
NegativeArraySizeException or IndexOutOfBounds instead (the actual
exception type depends on the value of reported negative length).
It is proposed to do two things:
1) remove the problematic sentence from the javadoc (CSR is filed).
2) unify the exception type thrown, if the argument reports negative length.
NegativeArraySizeException will be consistent with, for example,
StringBuffer(negativeCapacity).
Would you please help review the fix?
BUGURL: https://bugs.openjdk.java.net/browse/JDK-8218228
WEBREV: http://cr.openjdk.java.net/~igerasim/8218228/00/webrev/
CRS: https://bugs.openjdk.java.net/browse/JDK-8218649
--
With kind regards,
Ivan Gerasimov
More information about the core-libs-dev
mailing list