harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya Okomin (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2875) [classlib][awt] Compatibility: java.awt.image.Raster.getPixels() thows ArrayIndexOutOfBoundsException on Harmony and works silent on RI
Date Tue, 26 Dec 2006 10:55:21 GMT
[classlib][awt] Compatibility: java.awt.image.Raster.getPixels() thows ArrayIndexOutOfBoundsException
on Harmony and works silent on RI
---------------------------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-2875
                 URL: http://issues.apache.org/jira/browse/HARMONY-2875
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Ilya Okomin
            Priority: Minor


According to the specification for getPixels(int x,int y, int w, int h,  int/float/double[]
array)

"An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds. However,
explicit bounds checking is not guaranteed."

a)Harmony does not throw ArrayIndexOutOfBoundsException if y==Integer.MAX_VALUE and preallocated
array has integer type while RI does.

b)Harmony throws ArrayIndexOutOfBoundsException if y==Integer.MAX_VALUE and preallocated array
has float or double type while RI does not.

Run next Test case to reproduce, it fails on Harmony and successfully passes on RI:
------------- test.java --------------
import java.awt.Point;
import java.awt.image.BandedSampleModel;
import java.awt.image.DataBufferByte;
import java.awt.image.Raster;

import junit.framework.TestCase;
import junit.textui.TestRunner;

public class test extends TestCase {

    public static void main(String args[]) {
        TestRunner.run(test.class);
    }

    public void testCase1() {

        Raster rst = Raster.createRaster(new BandedSampleModel(1, 2, 3, 4),
                new DataBufferByte(new byte[191], 0), 
                new Point(new Point(28, 43)));
        try {
            rst.getPixels(6, Integer.MAX_VALUE, 1, 0, new int[] {});
            fail("ArrayIndexOutOfBoundsException should be thrown");
        } catch (ArrayIndexOutOfBoundsException e) {
            //expected
        }

    }

    public void testCase2() {

        Raster rst = Raster.createRaster(new BandedSampleModel(1, 2, 3, 4),
                new DataBufferByte(new byte[191], 0), 
                new Point(new Point(28,43)));
        rst.getPixels(6, Integer.MAX_VALUE, 1, 0, new float[] {});
    }

    public void testCase3() {

        Raster rst = Raster.createRaster(new BandedSampleModel(1, 2, 3, 4),
                new DataBufferByte(new byte[191], 0), new Point(new Point(28,
                        43)));
        rst.getPixels(6, Integer.MAX_VALUE, 1, 0, new double[] {});
    }
}

----------------------------------------

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