harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Khaschansky (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-650) [classlib][text]unexpected NPE for object constructed by java.text.Bidi(AttributedCharacterIterator)
Date Mon, 14 Aug 2006 17:08:14 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-650?page=comments#action_12427936 ] 
            
Oleg Khaschansky commented on HARMONY-650:
------------------------------------------

More investigation shows that the test above is incorrect. Correct test should check bidi.getRunLimit(0)
instead of bidi.getRunLimit(1), because there's only one directional run in the text. RI doesn't
throw ArrayIndexOutOfBounds exception only when the text has one directional run, otherwise
it throws this exception when run limit for non-existing run requested. Our implementation
will throw ArrayIndexOutOfBounds exception always when index for non-existing run supplied.
Spec says that this parameter should be between 0 and getRunCount(), but as RI behavior shows,
getRunCount() value is not included. Probably we have to open a separate compatibility issue
for the case when the text has only one directional run.

I suggest the following test for this issue:

import java.text.Bidi;
import java.text.AttributedString;

public class test { 
    public static void main(String[] args) {
        AttributedString paragraph = new AttributedString("text \u05d0\u05d1\u05d2");
                Bidi bidi = new Bidi(paragraph.getIterator());
                try {
                    System.out.println("Run count: " + bidi.getRunCount());
                    System.out.println("getRunLimit(0) = " + bidi.getRunLimit(0) + "\npassed!");
                    System.out.println("getRunLimit(1) = " + bidi.getRunLimit(1) + "\npassed!");
                } catch (Exception e) {
                    e.printStackTrace();
                    System.out.println("failed");
                }
                try {
                    System.out.println("getRunLimit(2) = " + bidi.getRunLimit(2) + "\nfailed!");
                } catch (Exception e) {
                    e.printStackTrace();
                    System.out.println("passed");
                }
    }
}

> [classlib][text]unexpected NPE for object constructed by java.text.Bidi(AttributedCharacterIterator)
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-650
>                 URL: http://issues.apache.org/jira/browse/HARMONY-650
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vladimir Ivanov
>         Attachments: BidiTest.patch
>
>
> The methods of object constructed by java.text.Bidi(AttributedCharacterIterator) throws
unexpected NPE on harmony classes while RI return correct value. For example, getRunLimit(1):
> ===================== test.java ====================
> import java.text.*; 
> public class test { 
>     public static void main (String[] args) {
>         AttributedString paragraph = new AttributedString("text");
>         Bidi bidi = new Bidi(paragraph.getIterator());
>         try {
>             System.out.println("getRunLimit(1) = " + bidi.getRunLimit(1) + "\npassed!");
>         } catch (Exception e) {
>             e.printStackTrace();
>             System.out.println("failed");
>         }
>     }
> } 
> ================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32,
> Native Threads, GC strategy: parallel)
> getRunLimit(1) = 4
> passed!
> C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as app
> licable.
> java.lang.NullPointerException
>         at java.text.Bidi.getRunLimit(Bidi.java:349)
>         at test.main(test.java:8)
> failed
> C:\tmp\tmp17>

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