RFR: 8372301: Improve error message for jimage command line tool regarding version mismatch

Alan Bateman alanb at openjdk.org
Sat Feb 14 08:02:36 UTC 2026


On Fri, 13 Feb 2026 20:59:09 GMT, David Beaumont <duke at openjdk.org> wrote:

> New implementation of improved JImageTask error message using string matching to detect the "version mismatch" error without needing code changes in the library.
> 
> Added tests for the error message and other ways in which the jimage file can be corrupt.

src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java line 200:

> 198:                 result.getMinorVersion() != ImageHeader.MINOR_VERSION) {
> 199:             // We rely on the sub-string "not the correct version" to detect
> 200:             // version issues in JImageTask and give a better user message.

Is there any reason not to introduce an ImageVersionMismatchException (extends IOException) to avoid depending on the message text? The jimage already imports jdk.tools.jlink.internal classes so adding an exception to this package is okay.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29723#discussion_r2807179766


More information about the core-libs-dev mailing list