On Wed, 18 Feb 2026 18:47:03 GMT, Phil Race <[email protected]> wrote:
>>> 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. I slept on this and I can't think of any legitimate use that needs a DataBuffer of size 0. Hope I'm right on this, since I've updated the code and the spec to disallow zero. Pushing that to the PR in just a few moments. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2830977478
