On Wed, 18 Feb 2026 07:32:37 GMT, Sergey Bylokhov <[email protected]> wrote:

>> Do you mean the equivalent of new DataBufferByte(0) ?
>> You get  a valid DataBuffer but there isn't a normal use for it.,
>
>> You get a valid DataBuffer but there isn't a normal use for it.,
> 
> Yes, calling any methods on it will cause an exception, right? In that case, 
> we should probably reject it? Or are there cases where an empty data buffer 
> could actually be useful?

I can't think of any use for it once it is created.

Because everything that uses a DataBuffer (in the imaging APIs) like Raster and 
BufferedImage require w/h of at least 1. So I'm not sure how a zero-length 
DataBuffer could ever be used once created.
And getElem() / setElem() can never be used either. 
The only use  would be in tests that see if you can create it  .. not a 
particularly practical real world use.

But because the spec. didn't disallow it, I didn't want to do anything about 
it. I tried to keep this change as much as possible to enforcing what the 
existing spec says. Already a tiny bit worried about breaking some weird code 
somewhere that ignores the spec.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2823894016

Reply via email to