You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vasily Zakharov (JIRA)" <ji...@apache.org> on 2007/01/16 18:41:28 UTC
[jira] Commented: (HARMONY-2777) [classlib][swing]
j.s.text.AbstractDocument.BranchElement.get{Start, End}Offset throw
ArrayIndexOutOfBoundsException rather than NPE
[ https://issues.apache.org/jira/browse/HARMONY-2777?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12465227 ]
Vasily Zakharov commented on HARMONY-2777:
------------------------------------------
javax.swing.text.AbstractDocumentTest fails on my system, probably due to this fix.
> [classlib][swing] j.s.text.AbstractDocument.BranchElement.get{Start, End}Offset throw ArrayIndexOutOfBoundsException rather than NPE
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-2777
> URL: https://issues.apache.org/jira/browse/HARMONY-2777
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Alexey A. Ivanov
> Assigned To: Mark Hindess
> Priority: Minor
> Attachments: H2777-AbstractDocument.patch, H2777-AbstractDocument_BranchElementTest.patch
>
>
> 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: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira