{"record":{"id":"ee3b6257c7b61882","repo":"oracle/graal","slug":"unexpected-architecture-architecture","errorCode":null,"errorMessage":"Unexpected architecture ${architecture}","messagePattern":"Unexpected architecture (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java","lineNumber":1137,"sourceCode":"\n    private static Throwable createThrowable(String className, String message) {\n        if (className.equals(JVMCIError.class.getName())) {\n            return new JVMCIError(message);\n        } else if (className.equals(GraalError.class.getName())) {\n            return new GraalError(message);\n        } else if (className.equals(IllegalArgumentException.class.getName())) {\n            return new IllegalArgumentException(message);\n        } else {\n            return new Throwable(message);\n        }\n    }\n\n    private static int architectureKind(Architecture architecture) {\n        return switch (architecture) {\n            case AMD64 ignored -> AMD64_ARCHITECTURE;\n            case RISCV64 ignored -> RISCV64_ARCHITECTURE;\n            case AArch64 ignored -> AARCH64_ARCHITECTURE;\n            default -> throw new IllegalArgumentException(\"Unexpected architecture \" + architecture);\n        };\n    }\n\n    private static void writeArchitectureFeatures(ObjectCopierOutputStream out, Architecture architecture) throws IOException {\n        switch (architecture) {\n            case AMD64 amd64 -> writeEnumOrdinals(out, amd64.getFeatures());\n            case RISCV64 riscv64 -> writeEnumOrdinals(out, riscv64.getFeatures());\n            case AArch64 aarch64 -> writeEnumOrdinals(out, aarch64.getFeatures());\n            default -> throw new IllegalArgumentException(\"Unexpected architecture \" + architecture);\n        }\n    }\n\n    private Architecture createFallbackArchitecture(String archName) {\n        if (!Platform.KNOWN_ARCHITECTURES.contains(archName)) {\n            throw new IllegalArgumentException(\"Unexpected architecture name \" + archName);\n        }\n        return hostTarget.arch;\n    }","sourceCodeStart":1119,"sourceCodeEnd":1155,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java#L1119-L1155","documentation":"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.","triggerScenarios":"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).","commonSituations":"Running GraalVM replay recording on an unsupported or in-development architecture port; unit tests constructing custom Architecture subclasses.","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"],"exampleFix":"// before\nint kind = architectureKind(arch); // throws on unsupported arch\n\n// after\nif (!(arch instanceof AMD64 || arch instanceof RISCV64 || arch instanceof AArch64)) {\n    // skip replay recording on this platform\n    return;\n}\nint kind = architectureKind(arch);","handlingStrategy":"type-guard","validationCode":"static boolean architectureSupported(Architecture a) {\n    return a instanceof AMD64 || a instanceof RISCV64 || a instanceof AArch64;\n}","typeGuard":"static boolean isReplaySupportedArchitecture(Architecture arch) {\n    return arch instanceof AMD64 || arch instanceof RISCV64 || arch instanceof AArch64;\n}","tryCatchPattern":"try {\n    codec.writeReplay(out);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unexpected architecture\")) {\n        // disable replay recording on this platform\n    } else throw e;\n}","preventionTips":["Enable replay recording only on amd64, riscv64 or aarch64","Gate recording behind a supported-architecture check at startup"],"tags":["graalvm","replay-compilation","architecture","unsupported-platform","serialization"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}