Hi,
 Please, help me to make clear JIRA HARMONY-2884.
RI throws RasterFormatException (Harmony doesn't) in the following case:

        DataBufferUShort db = new DataBufferUShort(new short[5], 3);
        SinglePixelPackedSampleModel sm = new 
                SinglePixelPackedSampleModel(1, 10, 1, 0, new int[431]);
        Raster localRaster = Raster.createRaster(sm, db, new Point());

Result:
 RasterFormatException: Data array too small (should be 10 )

Central numbers in this example - short[5] and 10.
RI compares DataBufferUShort.dataArray.length (==5) with
SampleModel.width (==10). RI supposes that (width - 1) should be less
than dataArray.length (Spec says nothing about this situation).
But here arises several questions:
1. Why width? Not (width * height)?
2. Why dataArray.length? Not dataArray.size?
   I'll explain this point. Spec says about DataBufferUShort(short[]
dataArray, int size):
        Constructs an unsigned-short based DataBuffer with a single bank
using   the specified array. Only the first "size" elements should be
used by         accessors of this DataBuffer. dataArray must be large
enough to hold  "size" elements.
   So, size criteria should be size, not length. Am I right?

Harmony doesn't produce any comparisons and this behavior doesn't
contradict spec. I suggest close this bug as non-bug diff.

Thanks,
Alexander Shipilov

Reply via email to