-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8369129: Raster createPackedRaster methods specification clean up #27627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back prr! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
Webrevs
|
* is less than 0 | ||
* @throws IllegalArgumentException if {@code pixelStride} is less than 0 | ||
* @throws IllegalArgumentException if {@code w * pixelStride} is greater | ||
* than {@code scanlineStride} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it still a valid point even for a single-line image, where scanlineStride would not be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
if (lsz > Integer.MAX_VALUE) { | ||
throw new IllegalArgumentException("size too large to store image"); | ||
} | ||
int size = (int)lsz; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it strange that in this method we reject "empty" images by requiring w and h to be greater than 0, but at the same time accept 0 as scanlineStride and pixelStride? This may result in empty image as well (size == 0), I think it will be rejected later but still should we check it here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We seem to have a number of APIs that allow the strides to be zero.
I find them odd, but I don't see how they can cause an empty image and they need careful consideration before changing. It seems very deliberate.
Here's a sampling of other cases (there are likely more, I searched very briefly and crudely)
* @throws IllegalArgumentException if {@code scanlineStride} is less than 0
public BandedSampleModel(int dataType,
int w, int h,
int scanlineStride,
int[] bankIndices,
int[] bandOffsets)
=====
* @throws IllegalArgumentException if {@code pixelStride} is less than 0
* @throws IllegalArgumentException if {@code scanlineStride} is less than 0
public ComponentSampleModel(int dataType,
int w, int h,
int pixelStride,
int scanlineStride,
int[] bandOffsets) {
=====
* @throws IllegalArgumentException if {@code pixelStride} is less than 0
* @throws IllegalArgumentException if {@code scanlineStride} is less than 0
public ComponentSampleModel(int dataType,
int w, int h,
int pixelStride,
int scanlineStride,
int[] bankIndices,
int[] bandOffsets) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS, also negative strides are something that we've been asked to support too - in the distant past.
But I don't have any plans to do it now.
Updates the specification of Raster.createPackedRaster(..) methods and also the implementation of these to explicitly check the specified conditions rather than relying on them being passed up from some other API.
Also one each of the createInterleavedRaster(..) and createBandedRaster(..) methods have an update
createInterleavedRaster(...) to address that even if WxH does not exceed Integer.MAX_VALUE, the storage needed still might.
createBandedRaster(..) to address
There's an unfortunate oddity with this that of bankIndices is null it specifies and throws AIOBE, but I didn't think it worth changing either of these to make them consistent.
The existing CreateRasterExceptionTest.java is updated to verify all these assertions.
In almost all cases the behaviour is unchanged, it is just now properly specified and verified up front.
There are only 2 sub-tests which would fail on JDK 25
The test can also be run (and pass) there without this fix because it explicitly handles those 2 cases which are reasonable behavioral changes
The CSR is now ready for review https://bugs.openjdk.org/browse/JDK-8369131
Progress
Issues
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27627/head:pull/27627
$ git checkout pull/27627
Update a local copy of the PR:
$ git checkout pull/27627
$ git pull https://git.openjdk.org/jdk.git pull/27627/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27627
View PR using the GUI difftool:
$ git pr show -t 27627
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27627.diff
Using Webrev
Link to Webrev Comment