harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey A. Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-1745) [classlib][swing] javax.swing.text.CompositeView.getView(int n) throws unspecified ArrayIndexOutOfBoundsException
Date Thu, 12 Oct 2006 10:26:39 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-1745?page=comments#action_12441690 ] 
            
Alexey A. Ivanov commented on HARMONY-1745:
-------------------------------------------

No, it's neither compatibility issue nor bug in implementation. As I said you'll get ArrayIndexOutOfBoundsException
if you call pv.getView(1) provided pv.getViewCount() returns 0 and no child views were ever
added.

Consider the following test case:
            Element localElement = new PlainDocument().getDefaultRootElement();
            ParagraphView pv = new ParagraphView(localElement);
            for (int i = 0; i < 2; i++) {
                pv.append(new PlainView(localElement));
            }
            pv.removeAll();
            System.out.println("pv.getViewCount() = " + pv.getViewCount());

            try {
                for (int i = 0; i <= 10; i++) {
                    System.out.print("got(" + i + "): " + pv.getView(i));
                    System.out.println("\tpassed");
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                System.out.println("Got ArrayIndexOutOfBoundsException");
            }


Then when run on the RI you'll get the following output:
pv.getViewCount() = 0
got(0): null    passed
got(1): null    passed
got(2): null    passed
got(3): null    passed
Got ArrayIndexOutOfBoundsException


When run on Harmony, you'll get ArrayIndexOutOfBoundsException on the first iteration of the
second loop (there will be no lines with "passed" printed). But remember that the pv object
has no child views since pv.getViewCount() = 0.

This is why I consider that this issue does relate only to the way child views are stored
internally. What do you suggest then? (You can experiment with other numbers.)

> [classlib][swing] javax.swing.text.CompositeView.getView(int n) throws unspecified ArrayIndexOutOfBoundsException
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1745
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1745
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Aleksey Victorivich Yantsen
>            Priority: Minor
>         Attachments: patch1745.txt
>
>
> Problem: CompositeView.getView(int) throws unspecified ArrayIndexOutOfBoundsException
while RI does not.
> Test to reproduce:
> import junit.framework.TestCase;
> import javax.swing.text.Element;
> import javax.swing.text.ParagraphView;
> import javax.swing.text.View;
> import javax.swing.text.html.HTMLDocument;
> public class Test extends TestCase {
> 	public void testcase() {
> 		HTMLDocument doc = new HTMLDocument();
> 		Element localElement = doc.getDefaultRootElement();
> 		ParagraphView pv = new ParagraphView(localElement);
> 		View v = null;
> 		try {
> 			v = pv.getView(0);
> 		} catch (ArrayIndexOutOfBoundsException e) {
> 			e.printStackTrace();
> 			fail("Got unexpected ArrayIndexOutOfBoundsException : " + e);
> 		}
> 	}
> }
> Output on Sun 1.5: 
> ================== 
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
> .
> Time: 0.125
> OK (1 test)
> Output on Harmony: 
> ================== 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or
its licensors, as applicable.
> java version "1.5.0" 
> pre-alpha : not complete or compatible
> svn = r453471, (Oct  6 2006), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> .java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
> 	at javax.swing.text.CompositeView.getView(CompositeView.java:56)
> 	at Test.testcase(Test.java:16)
> 	at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:258)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:16)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:19)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:28)
> 	at junit.framework.TestSuite.run(TestSuite.java:23)
> 	at junit.textui.TestRunner.doRun(TestRunner.java:116)
> 	at junit.textui.TestRunner.start(TestRunner.java:172)
> 	at junit.textui.TestRunner.main(TestRunner.java:138)
> F
> Time: 0.407
> There was 1 failure:
> 1) testcase(Test)junit.framework.AssertionFailedError: Got unexpected ArrayIndexOutOfBoundsException
: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
> 	at Test.testcase(Test.java:19)
> 	at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
> FAILURES!!!
> Tests run: 1,  Failures: 1,  Errors: 0

-- 
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

        

Mime
View raw message