Skip to content

Conversation

@david-beaumont
Copy link
Contributor

@david-beaumont david-beaumont commented Nov 21, 2025

Adds a semantic reason for failure which can be optionally interrogated by calling code.
Use the 'Reason.BAD_VERSION' value to trigger a different translated error message from the JImageTask.

I would consider moving the error message string into the Reason enum to simplify the code triggering the error and avoid message string duplication, but it's not straightforward due to the need to supply the version numbers.

We can use this approach to provide translated messages for all the distinct failure reasons if needed.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8372301: Improve error message for jimage command line tool regarding version mismatch (Sub-task - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28456/head:pull/28456
$ git checkout pull/28456

Update a local copy of the PR:
$ git checkout pull/28456
$ git pull https://git.openjdk.org/jdk.git pull/28456/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28456

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28456.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 21, 2025

👋 Welcome back david-beaumont! 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
Copy link

openjdk bot commented Nov 21, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Nov 21, 2025

@david-beaumont The following label will be automatically applied to this pull request:

  • core-libs

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

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 21, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 21, 2025

Webrevs

* Specialized {@link IOException} thrown during construction to provide a
* semantic reason for failure and allow better user-facing error messages.
*/
public final static class ImageError extends IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception names ending in "Error" are usually fatal to the VM, this seems more like a normal exception.
Generally, we don't add single purpose exceptions, they are little used and just contribute to bloat.

Copy link
Contributor Author

@david-beaumont david-beaumont Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How else do you think it best to reliably detect the semantic difference for the JImageTool while keeping the non-tool usage as it was? This new exception has a vital role for doing that which, if it, or something like it, didn't exist would be done via unsatisfying heuristics on the debug message string.

An alternate version would be to refactor things to have an "open()" method that returns a failure-reason type of some sort.

And the exception based approach would pave the way to properly translated strings for all the failure modes (though the others aren't actionable in as distinct a way).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants