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

java.awt.image.SampleModel.setSamples() methods not always throw ArrayIndexOutOfBoundsException

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      b138
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      The method
      public void setSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
      didn't throw ArrayIndexOutOfBoundsException in the following simple code:

      public class Sample {
          public static void main(String[] args) {
              int defaultWidth = 6;
              int defaultHeight = 4;
              SampleModel model =
                      Raster.createBandedRaster(DataBuffer.TYPE_INT, defaultWidth,
                              defaultHeight, 4, null).getSampleModel();
              DataBuffer data = model.createDataBuffer();
              int numElements = defaultWidth * defaultHeight * model.getNumBands();
              int[] a = new int[numElements];
              for (int j = 0; j < numElements; j++) {
                  a[j] = j;
              }
      model.setPixels(0, 0, defaultWidth, defaultHeight, a, data);
              float[] fArray = new float[defaultWidth * defaultHeight * model.getNumBands()];
              double[] dArray = new double[defaultWidth * defaultHeight * model.getNumBands()];
      model.setSamples(Integer.MAX_VALUE, 0, 1, 1, 0, fArray, data);
      System.out.println("setSamples works for x=2147483647, y=0, w=1 ,h=1");
          }
      }

      According to specification it should throw ArrayIndexOutOfBoundsException if the coordinates or the band index are not in bounds, or if iArray is too small to hold the input.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bae Andrew Brygin
                Reporter:
                afomin Alexander Fomin (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: