oracle/graal · error · IOException

Invalid replay boolean flag

Error message

Invalid replay boolean flag 

What it means

readBooleanFlag reads a single byte that must be exactly 0 or 1; anything else throws IOException 'Invalid replay boolean flag <value>'. Since writeBooleanFlag only ever writes 0 or 1, a different value can only mean the stream is corrupt or the reader is misaligned — some earlier value was parsed with a different length than it was written.

Source

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

        int version = in.readPackedUnsignedInt();
        if (version != VERSION) {
            throw new IOException("Unsupported replay file version " + version);
        }
    }

    private static void writeBooleanFlag(ObjectCopierOutputStream out, boolean value) throws IOException {
        out.write(value ? 1 : 0);
    }

    private static boolean readBooleanFlag(ObjectCopierInputStream in) throws IOException {
        int value = in.read();
        if (value < 0) {
            throw new EOFException();
        }
        return switch (value) {
            case 0 -> false;
            case 1 -> true;
            default -> throw new IOException("Invalid replay boolean flag " + value);
        };
    }

    private int registrationIndex(CompilerInterfaceDeclarations.Registration registration) {
        Integer index = registrationIndices.get(registration.clazz());
        if (index == null) {
            throw new IllegalArgumentException("Unknown registration " + registration.clazz().getName());
        }
        return index;
    }

    private static Object readSpecialSingleton(int kind) throws IOException {
        return switch (kind) {
            case SINGLETON_NULL_POINTER -> JavaConstant.NULL_POINTER;
            case SINGLETON_COMPRESSED_NULL -> HotSpotCompressedNullConstant.COMPRESSED_NULL;
            case SINGLETON_NO_SPECULATION -> SpeculationLog.NO_SPECULATION;
            case SINGLETON_ILLEGAL_VALUE_KIND -> ValueKind.Illegal;
            default -> throw new IOException("Unknown replay singleton kind " + kind);

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Regenerate the replay file with the same build used for replay (removes encoding skew)
  2. Verify the file version header matches before decoding
  3. If corruption is suspected, checksum or re-transfer the file and retry
Defensive patterns

Strategy: try-catch

Try / catch

try {
    result = codec.readReplay(in);
} catch (IOException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Invalid replay boolean flag")) {
        // stream corrupt or misaligned: discard file, re-record
    } else throw e;
}

Prevention

When it happens

Trigger: Stream corruption; an earlier readValue misconsumed bytes (version skew in encoding of a preceding field); reading a boolean at a position that is actually another value's payload.

Common situations: Cross-version replay where a preceding field's packed encoding changed; replay files damaged in transfer or truncated by a killed recording process.

Related errors


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