oracle/graal · error · IllegalArgumentException

Malformed HexCodeFile in

Error message

Malformed HexCodeFile in 

What it means

DisassemblerTool throws this IllegalArgumentException when HexCodeFile.parse returns null for a block delimited by the asm/hex-code markers in the input file. HexCodeFile.parse signals unrecoverable syntax problems by returning null (with diagnostics typically already emitted), and the tool converts that into an exception naming the input file. It means an embedded HexCodeFile block between the markers is not parseable as hex-plus-comment lines.

Source

Thrown at compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/disassembler/DisassemblerTool.java:121

                String source = input.substring(codeStart, endIndex);

                if (processingHotSpotAbstractAssembly) {
                    if (dis == null) {
                        dis = MachCode.initDisassembler(inputName, input, log, userArch);
                    }
                    String machCode = source.strip();
                    FailureReason fr = new FailureReason();
                    if (!new MachCode(dis).process(machCode, out, showComments, showBytes, fr)) {
                        out.println("# Could not disassemble MachCode: " + fr.getReason());
                        out.println(MACHCODE_OPEN);
                        out.println(machCode);
                        out.println(MACHCODE_CLOSE);
                    }
                } else {
                    HexCodeFile hcf = HexCodeFile.parse(input, codeStart, source, inputName);
                    if (hcf == null) {
                        throw new IllegalArgumentException("Malformed HexCodeFile in " + inputName);
                    }
                    new HexCodeFileDis(showComments, showBytes).process(hcf, out);
                }
                count++;
                codeEnd = endIndex;
            }
        }

        String copy = input.substring(codeEnd);
        if (copy.startsWith(endDelim)) {
            copy = copy.substring(endDelim.length());
        }

        if (log != null) {
            log.println(inputName + ": disassembled " + count + (processingHotSpotAbstractAssembly ? " MachCode sections" : " HexCodeFiles"));
        }
        out.print(copy);
        out.flush();

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Inspect the named input file around the block markers and fix or remove malformed hex lines (only hex bytes, optional '#'-comment columns, consistent address column).
  2. Re-generate the HexCodeFile with a matching GraalVM version instead of editing it by hand.
  3. Ensure the open/close delimiters are balanced and no stray delimiter text occurs inside the code block.
  4. Run with the tool's verbose/diagnostic options to see the parse errors HexCodeFile.parse recorded before returning null.

Example fix

// before (input block)
<hexcode>
0x0000: 55 48 89 e5
oops this line is prose
</hexcode>
// after
<hexcode>
0x0000: 55 48 89 e5
0x0004: c9 c3
</hexcode>
Defensive patterns

Strategy: try-catch

Validate before calling

HexCodeFile probe = HexCodeFile.parse(block, codeStart, blockText, inputName);
if (probe == null) { /* log diagnostics, skip block, or abort with context */ }

Try / catch

try { tool.run(inputName); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Malformed HexCodeFile")) { /* quarantine file, continue batch */ } else throw e; }

Prevention

When it happens

Trigger: Running the disassembler tool on a file whose "<hexcode>"-style block contains non-hex text, misaligned address columns, comments in an unexpected column format, or truncated content between the open and close delimiters. Only reached in the else-branch (non-MachCode input), i.e. classic HexCodeFile dumps such as IdealGraphStudio or test output.

Common situations: Feeding hand-edited disassembly dumps, files where line wrapping broke hex columns, or output from a different GraalVM version whose HexCodeFile comment format changed. Also when delimiters appear inside the payload, ending the block early and leaving garbage to parse.

Understand the failure class

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/79bdaa01458c3d9d. Report an issue: GitHub.