oracle/graal · error · IllegalArgumentException
Unexpected architecture ${architecture}
Error message
Unexpected architecture ${architecture} What it means
architectureKind maps a live Architecture instance to an architecture kind constant for encoding; the switch covers only AMD64, RISCV64 and AArch64, and anything else throws IllegalArgumentException 'Unexpected architecture <architecture>'. This is a write-path capability check: the codec can only record replays for those three supported architectures.
Source
Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java:1137
private static Throwable createThrowable(String className, String message) {
if (className.equals(JVMCIError.class.getName())) {
return new JVMCIError(message);
} else if (className.equals(GraalError.class.getName())) {
return new GraalError(message);
} else if (className.equals(IllegalArgumentException.class.getName())) {
return new IllegalArgumentException(message);
} else {
return new Throwable(message);
}
}
private static int architectureKind(Architecture architecture) {
return switch (architecture) {
case AMD64 ignored -> AMD64_ARCHITECTURE;
case RISCV64 ignored -> RISCV64_ARCHITECTURE;
case AArch64 ignored -> AARCH64_ARCHITECTURE;
default -> throw new IllegalArgumentException("Unexpected architecture " + architecture);
};
}
private static void writeArchitectureFeatures(ObjectCopierOutputStream out, Architecture architecture) throws IOException {
switch (architecture) {
case AMD64 amd64 -> writeEnumOrdinals(out, amd64.getFeatures());
case RISCV64 riscv64 -> writeEnumOrdinals(out, riscv64.getFeatures());
case AArch64 aarch64 -> writeEnumOrdinals(out, aarch64.getFeatures());
default -> throw new IllegalArgumentException("Unexpected architecture " + architecture);
}
}
private Architecture createFallbackArchitecture(String archName) {
if (!Platform.KNOWN_ARCHITECTURES.contains(archName)) {
throw new IllegalArgumentException("Unexpected architecture name " + archName);
}
return hostTarget.arch;
}View on GitHub (pinned to a66e9ccd1d)
Solutions
- Record the replay on a supported architecture (amd64, riscv64, aarch64)
- If porting, add the architecture to architectureKind, writeArchitectureFeatures and readArchitecture before enabling replay recording
- Guard before recording: only enable replay output when the host architecture is one of the three supported kinds
Example fix
// before
int kind = architectureKind(arch); // throws on unsupported arch
// after
if (!(arch instanceof AMD64 || arch instanceof RISCV64 || arch instanceof AArch64)) {
// skip replay recording on this platform
return;
}
int kind = architectureKind(arch); Defensive patterns
Strategy: type-guard
Validate before calling
static boolean architectureSupported(Architecture a) {
return a instanceof AMD64 || a instanceof RISCV64 || a instanceof AArch64;
} Type guard
static boolean isReplaySupportedArchitecture(Architecture arch) {
return arch instanceof AMD64 || arch instanceof RISCV64 || arch instanceof AArch64;
} Try / catch
try {
codec.writeReplay(out);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unexpected architecture")) {
// disable replay recording on this platform
} else throw e;
} Prevention
- Enable replay recording only on amd64, riscv64 or aarch64
- Gate recording behind a supported-architecture check at startup
When it happens
Trigger: Attempting to record a replay compilation while running on any architecture outside AMD64/RISCV64/AArch64 (e.g. a port in progress or an exotic platform).
Common situations: Running GraalVM replay recording on an unsupported or in-development architecture port; unit tests constructing custom Architecture subclasses.
Related errors
- Unexpected register config ${registerConfig}
- Unexpected marker
- No serializer for :
- Unknown registration
- Unexpected architecture name ${archName}
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/ee3b6257c7b61882.
Report an issue: GitHub.