{"record":{"id":"77169cbabb5f5dd3","repo":"oracle/graal","slug":"the-image-file-name-is-not-the-correct-version","errorCode":null,"errorMessage":"The image file \"{name}\" is not the correct version. Major: {major}. Minor: {minor}","messagePattern":"The image file \"(.+?)\" is not the correct version\\. Major: (.+?)\\. Minor: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/jimage/BasicImageReader.java","lineNumber":114,"sourceCode":"\n    public static final class NotAnImageFile extends IOException {\n        static final long serialVersionUID = -3240111096036918189L;\n    }\n\n    public static BasicImageReader open(Path path) throws IOException {\n        return new BasicImageReader(path, ByteOrder.nativeOrder());\n    }\n\n    private ImageHeader readHeader(IntBuffer buffer) throws IOException {\n        ImageHeader result = ImageHeader.readFrom(buffer);\n\n        if (result.getMagic() != ImageHeader.MAGIC) {\n            throw new NotAnImageFile();\n        }\n\n        if (result.getMajorVersion() != ImageHeader.MAJOR_VERSION ||\n                        result.getMinorVersion() != ImageHeader.MINOR_VERSION) {\n            throw new IOException(\"The image file \\\"\" + name + \"\\\" is not \" +\n                            \"the correct version. Major: \" + result.getMajorVersion() +\n                            \". Minor: \" + result.getMinorVersion());\n        }\n\n        return result;\n    }\n\n    private static ByteBuffer slice(ByteBuffer buffer, int position, int capacity) {\n        // Note that this is the only limit and position manipulation of\n        // BasicImageReader private ByteBuffers. The synchronize could be avoided\n        // by cloning the buffer to make a local copy, but at the cost of creating\n        // a new object.\n        synchronized (buffer) {\n            buffer.limit(position + capacity);\n            buffer.position(position);\n            return buffer.slice();\n        }\n    }","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/jimage/BasicImageReader.java#L96-L132","documentation":"While reading a jimage header, BasicImageReader checks magic, then major/minor version against ImageHeader.MAJOR_VERSION/MINOR_VERSION. A mismatch means the file is a jimage written by a different (incompatible) JDK image format version; an IOException with the found version numbers is thrown.","triggerScenarios":"Opening a jimage produced by a JDK whose image format differs from the one this Espresso build understands (e.g. newer/older JDK modules file passed via JavaHome).","commonSituations":"Running Espresso with a --java-home of a much newer or older JDK than the GraalVM build supports; mixing toolchains; custom-built jimage files with different format versions.","solutions":["Use a java home whose JDK version is supported by your GraalVM/Espresso release (check release notes for supported JDK versions).","If you deliberately need a different JDK's runtime, upgrade GraalVM to a matching distribution (Espresso tracks specific JDK versions).","Verify you are not pointing at a non-JDK directory that happens to contain a lib/modules file."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure the java home matches a JDK version supported by this GraalVM build\nString v = Files.readString(Path.of(javaHome, \"release\")).lines()\n    .filter(l -> l.startsWith(\"JAVA_VERSION=\")).findFirst().orElseThrow();\n// compare against the supported version list for your GraalVM release","typeGuard":null,"tryCatchPattern":"try {\n    reader = new BasicImageReader(path);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"not the correct version\")) { /* switch java home / upgrade GraalVM */ }\n}","preventionTips":["Pin java-home to a JDK version documented as supported by your GraalVM release.","Re-check supported versions on every GraalVM upgrade."],"tags":["espresso","jimage","version-mismatch","jdk"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}