harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Petrenko (JIRA)" <j...@apache.org>
Subject [jira] Assigned: (HARMONY-1584) [classlib][awt]Compatibility: java.awt.font.NumericShaper.shape() methods throw different exceptions for illegal parameters on RI and Harmony
Date Mon, 18 Dec 2006 12:48:26 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-1584?page=all ]

Alexey Petrenko reassigned HARMONY-1584:
----------------------------------------

    Assignee: Alexey Petrenko

> [classlib][awt]Compatibility: java.awt.font.NumericShaper.shape() methods throw different
exceptions for illegal parameters on RI and Harmony
> ---------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1584
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1584
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Ilya Okomin
>         Assigned To: Alexey Petrenko
>            Priority: Minor
>         Attachments: Harmony-1584-test.patch, Harmony-1584.patch
>
>
> If you pass illegal parameters for java.awt.font.NumericShaper.shape(char[], int, int)
and java.awt.font.NumericShaper.shape(char[], int, int, int) methods RI and Harmony will throw
different exceptions. Seems to be Harmony has illegal parameters check and RI just operate
with them without any consistency check. Mentioned check the same for both shape() methods.
You can run next tests and compare output:
> ---------------test.java-------------------
> import junit.framework.TestCase;
> import java.awt.font.NumericShaper;
> public class test extends TestCase {
>     public static void main(String[] args) {
>         junit.textui.TestRunner.run(test.class);
>     }
>     public void testShape4() {
>         int ranges = NumericShaper.ARABIC;
>         NumericShaper localNumericShaper = NumericShaper
>                 .getContextualShaper(ranges);
>         char[] chars = new char[] {};
>         int start = 0;
>         int count = 1;
>         int index = NumericShaper.ARABIC;
>         try {
>             localNumericShaper.shape(chars, start, count, index);
>             System.out.println("Fail!: len = 0: ArrayIndexOutOfBoundsException expected!");
>         } catch (Exception e) {
>             if (e instanceof ArrayIndexOutOfBoundsException){
>                 //  expected
>                 System.out.println("Success!: len = 0: " + e);
>             } else {
>                 //  expected
>                 System.out.println("Fail!: len = 0: " + e);
>             }
>         }
>         chars = new char[] {'a', 'b', 'c'};
>         start = -1;
>         count = 1;
>         try {
>             localNumericShaper.shape(chars, start, count, index);
>             System.out.println("Fail!: start < 0: ArrayIndexOutOfBoundsException expected!");
>         } catch (Exception e) {
>             if (e instanceof ArrayIndexOutOfBoundsException){
>                 //  expected
>                 System.out.println("Success!: start < 0: " + e);
>             } else {
>                 //  expected
>                 System.out.println("Fail!: start < 0: " + e);
>             }
>         }
>         // count < 0: silent run expected
>         start = 1;
>         count = -1;
>         try {
>             localNumericShaper.shape(chars, start, count, index);
>             System.out.println("Success!: count < 0: No exceptions thrown!");
>         } catch (Exception e) {
>             System.out.println("Fail!: count < 0: " + e);
>         }
>         start = 3;
>         count = 5;
>         try {
>             localNumericShaper.shape(chars, start, count, index);
>             System.out.println("Fail!: start + count > len: ArrayIndexOutOfBoundsException
expected!");
>         } catch (Exception e) {
>             if (e instanceof ArrayIndexOutOfBoundsException){
>                 //  expected
>                 System.out.println("Success!: start + count > len: " + e);
>             } else {
>                 System.out.println("Fail!: start + count > len: " + e);
>             }
>         }
>     }
>     
>     public void testShape3() {
>         int ranges = NumericShaper.ARABIC;
>         NumericShaper localNumericShaper = NumericShaper
>                 .getContextualShaper(ranges);
>         char[] chars = new char[] {};
>         int start = 0;
>         int count = 1;
>         try {
>             localNumericShaper.shape(chars, start, count);
>             System.out.println("Fail!: len = 0: ArrayIndexOutOfBoundsException expected!");
>         } catch (Exception e) {
>             if (e instanceof ArrayIndexOutOfBoundsException){
>                 //  expected
>                 System.out.println("Success!: len = 0: " + e);
>             } else {
>                 //  expected
>                 System.out.println("Fail!: len = 0: " + e);
>             }
>         }
>         chars = new char[] {'a', 'b', 'c'};
>         start = -1;
>         count = 1;
>         try {
>             localNumericShaper.shape(chars, start, count);
>             System.out.println("Fail!: start < 0: ArrayIndexOutOfBoundsException expected!");
>         } catch (Exception e) {
>             if (e instanceof ArrayIndexOutOfBoundsException){
>                 //  expected
>                 System.out.println("Success!: start < 0: " + e);
>             } else {
>                 //  expected
>                 System.out.println("Fail!: start < 0: " + e);
>             }
>         }
>         // count < 0: silent run expected
>         start = 1;
>         count = -1;
>         try {
>             localNumericShaper.shape(chars, start, count);
>             System.out.println("Success!: count < 0: No exceptions thrown!");
>         } catch (Exception e) {
>             System.out.println("Fail!: count < 0: " + e);
>         }
>         start = 3;
>         count = 5;
>         try {
>             localNumericShaper.shape(chars, start, count);
>             System.out.println("Fail!: start + count > len: ArrayIndexOutOfBoundsException
expected!");
>         } catch (Exception e) {
>             if (e instanceof ArrayIndexOutOfBoundsException){
>                 //  expected
>                 System.out.println("Success!: start + count > len: " + e);
>             } else {
>                 System.out.println("Fail!: start + count > len: " + e);
>             }
>         }
>     }
> }
> -----------------------------------------------
> ====== Output RI ======
> .Success!: len = 0: java.lang.ArrayIndexOutOfBoundsException
> Success!: start < 0: java.lang.ArrayIndexOutOfBoundsException
> Success!: count < 0: No exceptions thrown!
> Success!: start + count > len: java.lang.ArrayIndexOutOfBoundsException
> .Success!: len = 0: java.lang.ArrayIndexOutOfBoundsException
> Success!: start < 0: java.lang.ArrayIndexOutOfBoundsException
> Success!: count < 0: No exceptions thrown!
> Success!: start + count > len: java.lang.ArrayIndexOutOfBoundsException
> Time: 0.05
> OK (2 tests)
> ====== Output Harmony ======
> .Fail!: len = 0: java.lang.IndexOutOfBoundsException: start or count arguments are out
of text range
> Fail!: start < 0: java.lang.IndexOutOfBoundsException: start or count arguments are
out of text range
> Fail!: count < 0: java.lang.IllegalArgumentException: count argument must be positive
> Fail!: start + count > len: java.lang.IndexOutOfBoundsException: start or count arguments
are out of text range
> .Fail!: len = 0: java.lang.IndexOutOfBoundsException: start or count arguments are out
of text range
> Fail!: start < 0: java.lang.IndexOutOfBoundsException: start or count arguments are
out of text range
> Fail!: count < 0: java.lang.IllegalArgumentException: count argument must be positive
> Fail!: start + count > len: java.lang.IndexOutOfBoundsException: start or count arguments
are out of text range
> Time: 0.02
> OK (2 tests)
> The suggested fix is to remove parameters check in harmony, I'll provide patch. 

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