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

David Beaumont duke at openjdk.org
Mon Feb 16 21:03:24 UTC 2026


On Sat, 14 Feb 2026 07:59:52 GMT, Alan Bateman <alanb 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 tool already imports jdk.internal.jimage classes so adding an exception to this package is okay.

Discussing offline. See also:
https://github.com/openjdk/jdk/pull/28456/files/aa40f0c711cf5c02a243bda01d2e2d40d4b2b352#r2550365590

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

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


More information about the core-libs-dev mailing list