oracle/graal · error · IllegalArgumentException

Unexpected register config ${registerConfig}

Error message

Unexpected register config ${registerConfig}

What it means

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.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java:1192

        int size = in.readPackedUnsignedInt();
        EnumSet<E> enumSet = EnumSet.noneOf(enumClass);
        E[] constants = enumClass.getEnumConstants();
        for (int i = 0; i < size; i++) {
            int ordinal = in.readPackedUnsignedInt();
            if (ordinal < 0 || ordinal >= constants.length) {
                throw new IOException("Invalid ordinal " + ordinal + " for " + enumClass.getName());
            }
            enumSet.add(constants[ordinal]);
        }
        return enumSet;
    }

    private static int registerConfigKind(RegisterConfig registerConfig) {
        return switch (registerConfig) {
            case AMD64HotSpotRegisterConfig ignored -> AMD64_ARCHITECTURE;
            case RISCV64HotSpotRegisterConfig ignored -> RISCV64_ARCHITECTURE;
            case AArch64HotSpotRegisterConfig ignored -> AARCH64_ARCHITECTURE;
            default -> throw new IllegalArgumentException("Unexpected register config " + registerConfig);
        };
    }

    @SuppressWarnings("unchecked")
    private static RegisterConfig readRegisterConfig(ObjectCopierInputStream in, ReadState state) throws IOException {
        int kind = in.readPackedUnsignedInt();
        TargetDescription targetDescription = (TargetDescription) readValue(in, state);
        List<Register> allocatable = (List<Register>) readValue(in, state);
        return switch (kind) {
            case AMD64_ARCHITECTURE ->
                new AMD64HotSpotRegisterConfig(targetDescription, allocatable, readBooleanFlag(in));
            case RISCV64_ARCHITECTURE -> {
                readBooleanFlag(in);
                yield new RISCV64HotSpotRegisterConfig(targetDescription, allocatable);
            }
            case AARCH64_ARCHITECTURE -> {
                readBooleanFlag(in);
                yield new AArch64HotSpotRegisterConfig(targetDescription, allocatable);

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Record the replay on a supported architecture (amd64, riscv64, aarch64)
  2. When porting, add the new register config case to registerConfigKind and the matching readRegisterConfig branch
  3. Guard replay recording on supported architectures before serialization starts
Defensive patterns

Strategy: type-guard

Validate before calling

static boolean registerConfigSupported(RegisterConfig rc) {
    return rc instanceof AMD64HotSpotRegisterConfig
        || rc instanceof RISCV64HotSpotRegisterConfig
        || rc instanceof AArch64HotSpotRegisterConfig;
}

Type guard

static boolean isReplaySupportedRegisterConfig(RegisterConfig rc) {
    return rc instanceof AMD64HotSpotRegisterConfig
        || rc instanceof RISCV64HotSpotRegisterConfig
        || rc instanceof AArch64HotSpotRegisterConfig;
}

Try / catch

try {
    codec.writeReplay(out);
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Unexpected register config")) {
        // platform register config not supported by the replay codec: skip recording
    } else throw e;
}

Prevention

When it happens

Trigger: Recording a replay on a platform whose HotSpot register config class is none of the three known ones; custom RegisterConfig implementations reaching the codec.

Common situations: Unsupported or in-progress architecture ports; tests with synthetic RegisterConfig subclasses leaking into the replay writer.

Related errors


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