On Thu, 5 Mar 2026 18:19:49 GMT, Phil Race <[email protected]> wrote: >> How is `offset` allowed to be negative? >> >> [The >> specification](https://docs.oracle.com/en/java/javase/25/docs/api/java.desktop/java/awt/image/DataBuffer.html) >> for `DataBuffer` states, _“Getting or setting the 0th element of a bank, >> uses the (0+offset)th element of the array.”_ This statement implies the >> offset cannot be negative. > > There is a jtreg test that has been there since JDK 1.3 that expressly checks > negative is allowed. > (The test is in closed for no particularly good reason - it just never got > moved to open) > It just verifies that a negative offset is NOT rejected. > > The test came about because in JDK 1.3 development there was a change to > disallow negative offsets but it quickly had to be backed out because it > broke JAI - https://bugs.openjdk.org/browse/JDK-4308987 > > The client clearly can't access negative array elements, so I can only assume > that they ensure '-offset' is the smallest index they supply.
This is odd… Negative offset wasn't rejected, and someone used it… Surprising. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2927577410
