Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6773022

java.awt.image.SampleModel.getDataElements() does't throw ArrayIndexOutOfBoundsEx for Integer.MAX_V

XMLWordPrintable

    • 2d
    • b116
    • generic
    • generic, solaris
    • Verified

        The spec for java.awt.image.SampleModel.getDataElements() says:

        "@throws ArrayIndexOutOfBoundsException if the coordinates are not in bounds, or if obj is too small to hold the output."

        This exception is not thrown in all those cases. Please see the following code sample:
        ---
        import java.awt.image.*;

        public class Extract {

            public static void main(String[] args) {
                SampleModel model = Raster.createBandedRaster(DataBuffer.TYPE_INT, 10, 10, 4, null).getSampleModel();
                DataBuffer data = model.createDataBuffer();
                // No expected ArrayIndexOutOfBoundsException
                model.getDataElements(Integer.MAX_VALUE, 0, 1, 1, null, data);
                model.getDataElements(0, Integer.MAX_VALUE, 1, 1, null, data);
            }
        }
        ---

        This problems leads to failing JCK test:

        api/java_awt/Image/SampleModel/index.html#GetsetDataElements2[getsetDataElements20004]

        Platforms: Windows, Solaris
        JDK: 6, 7

              bae Andrew Brygin
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: