{"record":{"id":"cbe3c29f9c507e07","repo":"oracle/graal","slug":"the-image-file-name-is-corrupted","errorCode":null,"errorMessage":"The image file \"{name}\" is corrupted","messagePattern":"The image file \"(.+?)\" is corrupted","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":86,"sourceCode":"            do {\n                lastRead = channel.read(map);\n            } while (lastRead >= 0 && map.hasRemaining());\n        }\n\n        int headerSize = ImageHeader.getHeaderSize();\n        if (map.capacity() < headerSize) {\n            throw new NotAnImageFile();\n        }\n\n        // Interpret the image file header\n        header = readHeader(intBuffer(map, 0, headerSize));\n        indexSize = header.getIndexSize();\n\n        memoryMap = map.asReadOnlyBuffer();\n\n        // Interpret the image index\n        if (memoryMap.capacity() < indexSize) {\n            throw new IOException(\"The image file \\\"\" + name + \"\\\" is corrupted\");\n        }\n        redirect = intBuffer(memoryMap, header.getRedirectOffset(), header.getRedirectSize());\n        offsets = intBuffer(memoryMap, header.getOffsetsOffset(), header.getOffsetsSize());\n        locations = slice(memoryMap, header.getLocationsOffset(), header.getLocationsSize());\n        strings = slice(memoryMap, header.getStringsOffset(), header.getStringsSize());\n\n        stringsReader = new ImageStringsReader(strings);\n        decompressor = new Decompressor();\n    }\n\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","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/jimage/BasicImageReader.java#L68-L104","documentation":"BasicImageReader memory-maps a jimage file and validates that the mapped buffer is large enough for the header-declared index size. If memoryMap.capacity() < indexSize, the file's header claims an index larger than the file itself, so the file is truncated/corrupted and an IOException is thrown.","triggerScenarios":"Opening a modules jimage file that was truncated by a partial download/install, modified by a broken tool, or is on a filesystem returning short mmaps; Espresso locating a jimage via -version or custom java home.","commonSituations":"Corrupted or partially-extracted GraalVM/JDK installation; jimage patched by build tooling that rewrote offsets inconsistently; network filesystems delivering inconsistent file length.","solutions":["Verify the JDK/GraalVM installation: re-download and re-extract the JDK so lib/modules is intact.","Point Espresso at a known-good java home (espresso.JavaHome) and retry.","Compare file sizes/checksums of <java-home>/lib/modules against a reference installation.","If a custom jimage is used, rebuild it with a current jimage tool so header index size matches content."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Sanity-check the image before opening\nPath p = Path.of(javaHome, \"lib\", \"modules\");\nlong expected = referenceModulesSizeFor(jdkVersion);\nif (Files.size(p) != expected) { /* reinstall JDK */ }","typeGuard":null,"tryCatchPattern":"try {\n    reader = new BasicImageReader(path);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"corrupted\")) { /* re-extract JDK, verify checksum */ }\n}","preventionTips":["Install JDKs from verified archives and keep checksums.","Do not run GraalVM from partially-synced network mounts."],"tags":["espresso","jimage","corruption","installation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}