{"record":{"id":"a04b3e9c6429ddf3","repo":"oracle/graal","slug":"unexpected-register-config-registerconfig","errorCode":null,"errorMessage":"Unexpected register config ${registerConfig}","messagePattern":"Unexpected register config (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java","lineNumber":1192,"sourceCode":"        int size = in.readPackedUnsignedInt();\n        EnumSet<E> enumSet = EnumSet.noneOf(enumClass);\n        E[] constants = enumClass.getEnumConstants();\n        for (int i = 0; i < size; i++) {\n            int ordinal = in.readPackedUnsignedInt();\n            if (ordinal < 0 || ordinal >= constants.length) {\n                throw new IOException(\"Invalid ordinal \" + ordinal + \" for \" + enumClass.getName());\n            }\n            enumSet.add(constants[ordinal]);\n        }\n        return enumSet;\n    }\n\n    private static int registerConfigKind(RegisterConfig registerConfig) {\n        return switch (registerConfig) {\n            case AMD64HotSpotRegisterConfig ignored -> AMD64_ARCHITECTURE;\n            case RISCV64HotSpotRegisterConfig ignored -> RISCV64_ARCHITECTURE;\n            case AArch64HotSpotRegisterConfig ignored -> AARCH64_ARCHITECTURE;\n            default -> throw new IllegalArgumentException(\"Unexpected register config \" + registerConfig);\n        };\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private static RegisterConfig readRegisterConfig(ObjectCopierInputStream in, ReadState state) throws IOException {\n        int kind = in.readPackedUnsignedInt();\n        TargetDescription targetDescription = (TargetDescription) readValue(in, state);\n        List<Register> allocatable = (List<Register>) readValue(in, state);\n        return switch (kind) {\n            case AMD64_ARCHITECTURE ->\n                new AMD64HotSpotRegisterConfig(targetDescription, allocatable, readBooleanFlag(in));\n            case RISCV64_ARCHITECTURE -> {\n                readBooleanFlag(in);\n                yield new RISCV64HotSpotRegisterConfig(targetDescription, allocatable);\n            }\n            case AARCH64_ARCHITECTURE -> {\n                readBooleanFlag(in);\n                yield new AArch64HotSpotRegisterConfig(targetDescription, allocatable);","sourceCodeStart":1174,"sourceCodeEnd":1210,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java#L1174-L1210","documentation":"registerConfigKind maps a live RegisterConfig to an architecture kind constant for serialization; only AMD64HotSpotRegisterConfig, RISCV64HotSpotRegisterConfig and AArch64HotSpotRegisterConfig are handled, anything else throws IllegalArgumentException 'Unexpected register config <registerConfig>'. It is the write-side capability gate for the register-configuration section of a replay.","triggerScenarios":"Recording a replay on a platform whose HotSpot register config class is none of the three known ones; custom RegisterConfig implementations reaching the codec.","commonSituations":"Unsupported or in-progress architecture ports; tests with synthetic RegisterConfig subclasses leaking into the replay writer.","solutions":["Record the replay on a supported architecture (amd64, riscv64, aarch64)","When porting, add the new register config case to registerConfigKind and the matching readRegisterConfig branch","Guard replay recording on supported architectures before serialization starts"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"static boolean registerConfigSupported(RegisterConfig rc) {\n    return rc instanceof AMD64HotSpotRegisterConfig\n        || rc instanceof RISCV64HotSpotRegisterConfig\n        || rc instanceof AArch64HotSpotRegisterConfig;\n}","typeGuard":"static boolean isReplaySupportedRegisterConfig(RegisterConfig rc) {\n    return rc instanceof AMD64HotSpotRegisterConfig\n        || rc instanceof RISCV64HotSpotRegisterConfig\n        || rc instanceof AArch64HotSpotRegisterConfig;\n}","tryCatchPattern":"try {\n    codec.writeReplay(out);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unexpected register config\")) {\n        // platform register config not supported by the replay codec: skip recording\n    } else throw e;\n}","preventionTips":["Enable replay recording only on platforms whose HotSpot register configs the codec knows","When porting, extend registerConfigKind and readRegisterConfig together"],"tags":["graalvm","replay-compilation","register-config","unsupported-platform","serialization"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}