On Wed, 17 Aug 2022 06:57:00 GMT, Tejesh R <[email protected]> wrote:
>> The Document for _DefaultStyledDocument.setCharacterAttribute_ states that
>> the range of length accepted is `length - the length >= 0`, whereas in code
>> the length check is done only for `length==0`. Meaning the control just
>> returns if the `length` is 0. Since length is _int_ type and there is a
>> possibility of negative length being set through the method, the code
>> doesn't actually handles the negative length case. Hence to handle negative
>> length, negative length check has been added along with 0 check. Its safe to
>> check and return the control for `negative` length input. Test case to check
>> the same is added.
>
> Tejesh R has updated the pull request incrementally with two additional
> commits since the last revision:
>
> - Merge branch 'branch_8291792' of github.com:TejeshR13/jdk into
> branch_8291792
> - Moved test to test/jdk/javax/swing/DefaultStyledDocument
src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java line
500:
> 498: */
> 499: public void setCharacterAttributes(int offset, int length,
> AttributeSet s, boolean replace) {
> 500: if (length <= 0) {
@param length the length >= 0 javadoc should it not be then > 0 ?
test/jdk/javax/swing/text/DefaultStyledDocument/DocNegLenCharAttrTest.java line
47:
> 45: */
> 46: public class DocNegLenCharAttrTest {
> 47: private static DefaultStyledDocument doc;
guess it can be local variable in test()
-------------
PR: https://git.openjdk.org/jdk/pull/9830