Skip to content
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

8255800: Raster creation methods need some specification clean up #3223

Closed
wants to merge 3 commits into from
Closed

8255800: Raster creation methods need some specification clean up #3223

wants to merge 3 commits into from

Conversation

@prrace
Copy link
Contributor

@prrace prrace commented Mar 26, 2021

https://bugs.openjdk.java.net/browse/JDK-8255800 could have been a one line spec clean up but
it didn't take a lot of looking to realize there were many more inconsistencies between spec and implementation.
I've spent a lot of time on what is just small number of factory methods in Raster because there are so
many possible exceptions and in some cases they rely on other API they call to generate exceptions and
these may have not been documented or documented acc. to some long lost behavior.
I've mostly tried to ONLY change spec. But I couldn't help myself when some checks were missed that
ended up with bizarre and dubious behavior - throwing NegativeArrayIndexException which just about
always has to be an internal bug !

The supplied test passes on JDK 16 as well as this code, because the (relatively) small number of
cases where JDK 16 threw NegativeArrayIndexException are caught and allowed only for releases < 17
So where you see those in the test it corresponds to the behavioral changes from NegativeArrayIndexException
to IllegalArgumentException.
JCK conformance tests still pass so they must not test those conditions.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8255800: Raster creation methods need some specification clean up

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3223/head:pull/3223
$ git checkout pull/3223

Update a local copy of the PR:
$ git checkout pull/3223
$ git pull https://git.openjdk.java.net/jdk pull/3223/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3223

View PR using the GUI difftool:
$ git pr show -t 3223

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3223.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 26, 2021

👋 Welcome back prr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Mar 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@prrace The following labels will be automatically applied to this pull request:

  • 2d
  • awt

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 26, 2021

Webrevs

@prrace
Copy link
Contributor Author

@prrace prrace commented Mar 26, 2021

oh and yes I know this requires a CSR ! But I want to do the code review first and then submit a CSR based on the approved version.

@prrace
Copy link
Contributor Author

@prrace prrace commented Mar 26, 2021

/csr

@openjdk openjdk bot added the csr label Mar 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@prrace has indicated that a compatibility and specification (CSR) request is needed for this pull request.
@prrace please create a CSR request and add link to it in JDK-8255800. This pull request cannot be integrated until the CSR request is approved.

* and {@code h} is greater than {@code Integer.MAX_VALUE}
* @throws IllegalArgumentException if {@code pixelStride} is less than 0
* @throws IllegalArgumentException if {@code scanlineStride} is less than 0
* @throws NullPointerException if {@code bandOffsets} is {@code null}
Copy link
Member

@mrserb mrserb Mar 26, 2021

I like the NPE here, but probably it makes sense to use the same exception for all errors? "IllegalArgumentException "

Copy link
Contributor Author

@prrace prrace Mar 26, 2021

Meaning even though you like the NPE you would change it to IAE like the rest ?

Copy link
Member

@mrserb mrserb Mar 31, 2021

Yes and no, I just wanted to highlight this place, since somebody may prefer IAE here.

Copy link
Contributor Author

@prrace prrace Mar 31, 2021

Well IAE was my initial thought but I decided to minimize the behavioral changes.

* and {@code h} is greater than {@code Integer.MAX_VALUE}
* @throws IllegalArgumentException if {@code pixelStride} is less than 0
* @throws IllegalArgumentException if {@code scanlineStride} is less than 0
* @throws NullPointerException if {@code bandOffsets} is {@code null}
Copy link
Member

@mrserb mrserb Mar 31, 2021

Yes and no, I just wanted to highlight this place, since somebody may prefer IAE here.

* @throws IllegalArgumentException if {@code w} and {@code h} are not
* both > 0
* @throws IllegalArgumentException if the product of {@code w}
* and {@code h} is greater than {@code Integer.MAX_VALUE}
Copy link
Member

@mrserb mrserb Mar 31, 2021

Do we really want to specify this? I hit this bug during HiDPI work and it seems this is an implementation bug that we do not support big size(w*h).

Copy link
Contributor Author

@prrace prrace Mar 31, 2021

The implementation issues that constrain this are substantial.
I find it unlikely we'd find a reason to support it.
I mean a bigger issue is we can'r even support an image that's Integer.MAX_VALUE wide and 1 pixel high.

Removing this from the spec. at that time would be trivial compared to the work in supporting it.
And likely it would be some other method that would support that anyway for the aforementioned int reason.
And we also (and always have) documented an exception if adding the location.x + w would overflow an int.
So in summary, yes, let's document it.

* one of the supported data types, which are
* {@code DataBuffer.TYPE_BYTE},
* {@code DataBuffer.TYPE_USHORT}
* or {@code DataBuffer.TYPE_INT}
Copy link
Member

@mrserb mrserb Mar 31, 2021

What about other types like TYPE_SHORT or we assume it is unsupported?

Copy link
Contributor Author

@prrace prrace Mar 31, 2021

The existing code throws IAE if it is not one of these exact types. See around line 460 in this updated file.
And that code is in a public factory method called by this factory method. And that callee has exactly this documentation. So I am just copying it over so that it is consistently documented.

mrserb
mrserb approved these changes Apr 1, 2021
@prrace
Copy link
Contributor Author

@prrace prrace commented Apr 1, 2021

I've updated the PR with one very minor typo correction and a removal of a duplicate throws clause.
Also I've prepared a draft CSR which needs to be reviewed https://bugs.openjdk.java.net/browse/JDK-8264625

mrserb
mrserb approved these changes Apr 2, 2021
@prrace
Copy link
Contributor Author

@prrace prrace commented Apr 2, 2021

I updated the fix with some additional checks. This is implementation only - doesn't affect the spec clarification.
The problem was that without these new upfront checks for overflow of width+location.x, then on systems without
enough memory/swap you'd get an OOME before you got to the place where overflow was checked.

@openjdk openjdk bot removed the csr label Apr 6, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 6, 2021

@prrace This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8255800: Raster creation methods need some specification clean up

Reviewed-by: serb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 132 new commits pushed to the master branch:

  • eb5c097: 8262389: Use permitted_enctypes if default_tkt_enctypes or default_tgs_enctypes is not present
  • bfb034a: 8264524: jdk/internal/platform/docker/TestDockerMemoryMetrics.java fails due to swapping not working
  • a756d8d: 8264759: x86_32 Minimal VM build failure after JDK-8262355
  • 0f13e22: 8264791: java/util/Random/RandomTestBsi1999.java failed "java.security.SecureRandom nextFloat consecutive"
  • 4bb80f3: 8262898: com/sun/net/httpserver/bugs/8199849/ParamTest.java times out
  • 2f51699: 8264554: X509KeyManagerImpl calls getProtectionParameter with incorrect alias
  • 114e3c3: 8263856: Github Actions for macos/aarch64 cross-build
  • a611c46: 8264048: Fix caching in Jar URL connections when an entry is missing
  • bf26a25: 8264027: Refactor "CLEANUP" region printing
  • eb6330e: 8264047: Duplicate global variable 'jvm' in libjavajpeg and libawt
  • ... and 122 more: https://git.openjdk.java.net/jdk/compare/7284f013ea3064b2aa643658938ccaafdfa1c885...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Apr 6, 2021
mrserb
mrserb approved these changes Apr 7, 2021
@prrace
Copy link
Contributor Author

@prrace prrace commented Apr 7, 2021

/integrate

@openjdk openjdk bot closed this Apr 7, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Apr 7, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 7, 2021

@prrace Since your change was applied there have been 136 commits pushed to the master branch:

  • eab8455: 8261137: Optimization of Box nodes in uncommon_trap
  • 92fad1b: 8264680: Use the blessed modifier order in java.desktop
  • 17202c8: 8264748: Do not include arguments.hpp from compilerDefinitions.hpp
  • c3abdc9: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp
  • eb5c097: 8262389: Use permitted_enctypes if default_tkt_enctypes or default_tgs_enctypes is not present
  • bfb034a: 8264524: jdk/internal/platform/docker/TestDockerMemoryMetrics.java fails due to swapping not working
  • a756d8d: 8264759: x86_32 Minimal VM build failure after JDK-8262355
  • 0f13e22: 8264791: java/util/Random/RandomTestBsi1999.java failed "java.security.SecureRandom nextFloat consecutive"
  • 4bb80f3: 8262898: com/sun/net/httpserver/bugs/8199849/ParamTest.java times out
  • 2f51699: 8264554: X509KeyManagerImpl calls getProtectionParameter with incorrect alias
  • ... and 126 more: https://git.openjdk.java.net/jdk/compare/7284f013ea3064b2aa643658938ccaafdfa1c885...master

Your commit was automatically rebased without conflicts.

Pushed as commit adb860e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@prrace prrace deleted the raster branch Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants