oracle/graal · error · IllegalArgumentException

Unsupported architecture %s: %s

Error message

Unsupported architecture %s: %s

What it means

MachCode.fromArch maps an architecture name string to a Disassembler and throws this formatted IllegalArgumentException for any string other than x86_64/amd64/x64 or aarch64. The message intentionally embeds a second context string (typically where the arch name came from), so the full text tells you both the unrecognized value and its provenance. Only the two hsdis-backed ISAs are constructible.

Source

Thrown at compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/disassembler/MachCode.java:111

            if (newHsErrContent.equals(hsErrContent)) {
                System.out.printf("No MachCode sections in %s or they could not be disassembled: %s%n", hsErr, fr.getReason());
            } else {
                Path newHsErrFile = Paths.get(hsErrFile + ".dis");
                Files.write(newHsErrFile, newHsErrContent.getBytes(StandardCharsets.UTF_8));
                System.out.println(" In: " + hsErrFile);
                System.out.println("Out: " + newHsErrFile);
            }
        }
    }

    private static Disassembler fromArch(String arch, String message) {
        if (arch.equals("x86_64") || arch.equals("amd64") || arch.equals("x64")) {
            return new HotSpotDisassembler(Disassembler.Architecture.AMD64);
        }
        if (arch.equals("aarch64")) {
            return new HotSpotDisassembler(Disassembler.Architecture.AArch64);
        }
        throw new IllegalArgumentException(String.format("Unsupported architecture %s: %s", arch, message));
    }

    /**
     * Gets a {@link Disassembler} instance that can disassemble machine code for the CPU type
     * specified heuristic probing of {@code input} based on typical patterns found in hs_err logs
     * or .jtr files. If heuristic probing fails and {@code userArch != null}, then it is used
     * otherwise the {@code machcode.arch} or {@code os.arch} system property is used.
     *
     * @param log if non-null, log messages are printed here
     */
    public static Disassembler initDisassembler(String inputName, String input, PrintStream log, String userArch) {
        if (userArch != null) {
            return fromArch(userArch, "User requested");
        }

        Pattern osArch = Pattern.compile("os\\.arch\\s*=\\s*(\\w+)");
        Pattern amd64 = Pattern.compile("\\W(amd64|x86_64|x64)(\\W|$)");
        Pattern aarch64 = Pattern.compile("\\Waarch64(\\W|$)");

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Pass one of the recognized spellings: x86_64, amd64, x64, or aarch64.
  2. If arch is optional for your flow, pass null so MachCode falls back to heuristics/os.arch instead of an invalid literal.
  3. Normalize user input (trim, lowercase, map 'arm64'->'aarch64') before handing it to fromArch.
  4. For genuinely unsupported ISAs, use a different disassembler backend; this path cannot serve them.

Example fix

// before
Disassembler d = MachCode.initDisassembler(f, input, log, "arm"); // throws
// after
String arch = normalize(userArch); // maps arm64->aarch64, null stays null
Disassembler d = MachCode.initDisassembler(f, input, log, arch);
Defensive patterns

Strategy: validation

Validate before calling

static String normalizeArch(String a) {
    if (a == null) return null;
    return switch (a.trim().toLowerCase()) {
        case "amd64", "x86_64", "x64" -> "amd64";
        case "aarch64", "arm64" -> "aarch64";
        default -> throw new IllegalArgumentException("unsupported arch: " + a);
    };
}

Try / catch

try { MachCode.initDisassembler(name, input, log, userArch); } catch (IllegalArgumentException e) { /* show supported values amd64/x64/aarch64 to the user */ }

Prevention

When it happens

Trigger: Calling MachCode.initDisassembler / fromArch with userArch set to an unsupported value (e.g. "riscv", "ppc64", empty-but-nonnull), or heuristic probing passing through an arch string parsed from an input file that is not one of the recognized spellings.

Common situations: Users passing a bad --arch flag to a disassembler CLI built on MachCode, or processing hs_err/.jtr files whose architecture line names an ISA GraalVM's hsdis does not cover.

Related errors


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