RFR: 4954405: Data buffers created with an offset are unusable
Andrey Turbanov
aturbanov at openjdk.org
Wed Oct 15 08:39:16 UTC 2025
On Tue, 14 Oct 2025 03:29:00 GMT, Phil Race <prr at openjdk.org> wrote:
> ByteInterleavedRaster is not including the DataBuffer offset in returns from getDataElements
> The super-class sets it in the constructor which runs very much like this subclass except it omits this.
> The parent class of ByteInterleavedRaster is ByteComponentRaster and it uses the DataBuffer offset
> to adjust dataOffsets values used in all calculations.
>
> Instead ByteInterleavedRaster does something a bit different than other classes where it includes it in some instance vars
> that also have additional offsets that apply for getPixels and getSamples but aren't used in getDataElements.
>
> It looks to me as if this is what ByteInterleavedRaster should also do instead.
> All existing tests pass, and this resolves the specific complaint in the bug report.
test/jdk/java/awt/image/ByteInterleavedRasterOffsetsTest.java line 48:
> 46: Raster.createInterleavedRaster(databuf, 1, 1, 3, 3, bandOffsets, null);
> 47: int[] pixels = raster.getPixels(0, 0, 1, 1, (int[])null);
> 48: byte[] elements = (byte[])raster.getDataElements(0, 0,null);
Suggestion:
byte[] elements = (byte[])raster.getDataElements(0, 0, null);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27782#discussion_r2431635679
More information about the client-libs-dev
mailing list