{"record":{"id":"f24e4474e7263a2a","repo":"oracle/graal","slug":"required-replay-field-is-null","errorCode":null,"errorMessage":"Required replay field  is null","messagePattern":"Required replay field  is null","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java","lineNumber":1106,"sourceCode":"    private static Object readSpecialSingleton(int kind) throws IOException {\n        return switch (kind) {\n            case SINGLETON_NULL_POINTER -> JavaConstant.NULL_POINTER;\n            case SINGLETON_COMPRESSED_NULL -> HotSpotCompressedNullConstant.COMPRESSED_NULL;\n            case SINGLETON_NO_SPECULATION -> SpeculationLog.NO_SPECULATION;\n            case SINGLETON_ILLEGAL_VALUE_KIND -> ValueKind.Illegal;\n            default -> throw new IOException(\"Unknown replay singleton kind \" + kind);\n        };\n    }\n\n    private Class<?> arrayComponentType(Object[] array) {\n        Class<?> componentType = array.getClass().getComponentType();\n        Class<?> registeredSupertype = declarations.findRegisteredSupertype(componentType);\n        return (registeredSupertype != null) ? registeredSupertype : componentType;\n    }\n\n    private static String requireNonNullString(String value, String description) throws IOException {\n        if (value == null) {\n            throw new IOException(\"Required replay field \" + description + \" is null\");\n        }\n        return value;\n    }\n\n    private static Register findRegister(Architecture architecture, int number) throws IOException {\n        for (Register register : architecture.getRegisters()) {\n            if (register.number == number) {\n                return register;\n            }\n        }\n        throw new IOException(\"Register \" + number + \" not found in \" + architecture.getName());\n    }\n\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);","sourceCodeStart":1088,"sourceCodeEnd":1124,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java#L1088-L1124","documentation":"requireNonNullString is the codec's guard for string fields that must never be null in a valid stream (enum class, field holder, method name, throwables, etc.). When readStringReference returns null for such a position, it throws IOException 'Required replay field <description> is null'. A null here means either the stream explicitly contained a NULL_TAG where a required string was expected, or the reader is misaligned.","triggerScenarios":"A NULL_TAG appearing where the format mandates a string (writer bug or hand-crafted stream); misaligned reads after an earlier decode discrepancy; a recording bug that serialized a null name/class.","commonSituations":"Replaying files from an experimental build that allowed null where the current format forbids it; corrupted streams after truncation.","solutions":["Regenerate the replay file with a build whose codec never writes null for that field","Verify version compatibility before decode","If writing a codec extension, never emit NULL_TAG for fields documented as required"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// on the writer side: never write null for required string fields\nstatic void writeRequiredString(ObjectCopierOutputStream out, String s) {\n    if (s == null) throw new IllegalStateException(\"required string must not be null\");\n    // ... write reference\n}","typeGuard":null,"tryCatchPattern":"try {\n    result = codec.readReplay(in);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Required replay field\")) {\n        // malformed recording: re-record the file\n    } else throw e;\n}","preventionTips":["When extending the codec, treat names/classes/holders as mandatory non-null strings","Round-trip test every new record type to prove no null sneaks into required positions"],"tags":["graalvm","replay-compilation","deserialization","null-safety","validation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}