You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexey A. Ivanov (JIRA)" <ji...@apache.org> on 2006/12/18 14:43:22 UTC

[jira] Updated: (HARMONY-2777) [classlib][swing] j.s.text.AbstractDocument.BranchElement.get{Start, End}Offset throw ArrayIndexOutOfBoundsException rather than NPE

     [ http://issues.apache.org/jira/browse/HARMONY-2777?page=all ]

Alexey A. Ivanov updated HARMONY-2777:
--------------------------------------

    Estimated Complexity: Novice

> [classlib][swing] j.s.text.AbstractDocument.BranchElement.get{Start, End}Offset throw ArrayIndexOutOfBoundsException rather than NPE
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2777
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2777
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Alexey A. Ivanov
>            Priority: Minor
>
> The spec states that getEndOffset throws NPE if the element has no children [1].
> The spec doesn't say anything about exceptions for getStartOffset() [2]. However, it also throws NPE in this case. The behavior of these methods should be similar in respect to exceptions.
> [1] http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/AbstractDocument.BranchElement.html#getEndOffset()
> [2] http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/AbstractDocument.BranchElement.html#getStartOffset()
> ======= Code to Reproduce =======
> import javax.swing.text.PlainDocument;
> import javax.swing.text.AbstractDocument.BranchElement;
> public class Test {
>     public static void main(String[] args) {
>         PlainDocument doc = new PlainDocument();
>         BranchElement branch = doc.new BranchElement(null, null);
>         try {
>             System.err.println(branch.getStartOffset());
>         } catch (Exception e) {
>             System.err.println("getStartOffset:");
>             e.printStackTrace();
>         }
>         try {
>             System.err.println(branch.getEndOffset());
>         } catch (Exception e) {
>             System.err.println("getEndOffset:");
>             e.printStackTrace();
>         }
>     }
> }
> ======= end of code =======
> ------- Harmony Output -------
> getStartOffset:
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
> 	at javax.swing.text.AbstractDocument$BranchElement.getStartOffset(AbstractDocument.java:419)
> 	at Test.main(Test.java:9)
> getEndOffset:
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -1
> 	at javax.swing.text.AbstractDocument$BranchElement.getEndOffset(AbstractDocument.java:48)
> 	at Test.main(Test.java:15)
> ------- end of Harmony -------
> ------- RI Output -------
> getStartOffset:
> java.lang.NullPointerException
> 	at javax.swing.text.AbstractDocument$BranchElement.getStartOffset(AbstractDocument.java:2331)
> 	at Test.main(Test.java:9)
> getEndOffset:
> java.lang.NullPointerException
> 	at javax.swing.text.AbstractDocument$BranchElement.getEndOffset(AbstractDocument.java:2343)
> 	at Test.main(Test.java:15)
> ------- end of RI -------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira