{"record":{"id":"25e8482aefa57d5a","repo":"oracle/graal","slug":"unexpected-marker","errorCode":null,"errorMessage":"Unexpected marker ","messagePattern":"Unexpected marker ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java","lineNumber":589,"sourceCode":"                out.writePackedUnsignedInt(doubles.length);\n                for (double d : doubles) {\n                    out.writeDoublePrimitive(d);\n                }\n            }\n            case SpecialResultMarker.ExceptionThrownMarker marker -> {\n                out.write(RESULT_MARKER_TAG);\n                out.writePackedUnsignedInt(RESULT_EXCEPTION);\n                writeValue(out, marker.getThrown(), state);\n            }\n            case SpecialResultMarker marker -> {\n                out.write(RESULT_MARKER_TAG);\n                int markerKind;\n                if (marker == SpecialResultMarker.NO_RESULT_MARKER) {\n                    markerKind = RESULT_NO_RESULT;\n                } else if (marker == SpecialResultMarker.NULL_RESULT_MARKER) {\n                    markerKind = RESULT_NULL;\n                } else {\n                    throw new IllegalArgumentException(\"Unexpected marker \" + marker);\n                }\n                out.writePackedUnsignedInt(markerKind);\n            }\n            case StackTraceElement ste -> {\n                out.write(STACK_TRACE_ELEMENT_TAG);\n                writeStringReference(out, ste.getClassLoaderName(), state);\n                writeStringReference(out, ste.getModuleName(), state);\n                writeStringReference(out, ste.getModuleVersion(), state);\n                writeStringReference(out, ste.getClassName(), state);\n                writeStringReference(out, ste.getMethodName(), state);\n                writeStringReference(out, ste.getFileName(), state);\n                out.writePackedSignedInt(ste.getLineNumber());\n            }\n            case Register register -> {\n                out.write(REGISTER_TAG);\n                out.writePackedUnsignedInt(register.number);\n            }\n            case Field field -> {","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/BinaryReplayCodec.java#L571-L607","documentation":"Thrown by BinaryReplayCodec.writeValue when a SpecialResultMarker value is neither NO_RESULT_MARKER nor NULL_RESULT_MARKER while serializing a compilation result marker. The codec only knows how to encode those two singleton markers (exception-throwing markers take a different branch), so any other SpecialResultMarker subtype is unencodable. It surfaces as an IllegalArgumentException during writing of a replay file.","triggerScenarios":"Calling the replay writer with a SpecialResultMarker instance that is a new subclass (e.g. a newly added marker kind) or a hand-constructed anonymous subclass; the pattern match 'case SpecialResultMarker marker' falls into the else branch and rejects it.","commonSituations":"Extending the replay-compilation framework with a new special result marker type without teaching the codec a new RESULT_* kind; passing test doubles or mocks of SpecialResultMarker into recorded compilation results.","solutions":["If you introduced a new SpecialResultMarker subtype, add a corresponding RESULT_* constant and a write branch (plus a matching read case in the RESULT_MARKER_TAG switch)","If you control the value, pass only SpecialResultMarker.NO_RESULT_MARKER or NULL_RESULT_MARKER, or use the exception-thrown marker which is handled by its own case","Check the marker before recording: filter unsupported markers out of the recorded result"],"exampleFix":"// before\nSpecialResultMarker marker = myCustomMarker; // new subtype\nwriteValue(out, marker, state);\n\n// after\nif (marker == SpecialResultMarker.NO_RESULT_MARKER || marker == SpecialResultMarker.NULL_RESULT_MARKER\n                || marker instanceof SpecialResultMarker.ExceptionThrownMarker) {\n    writeValue(out, marker, state);\n} else {\n    throw new IllegalArgumentException(\"Unexpected marker \" + marker);\n}","handlingStrategy":"type-guard","validationCode":"boolean encodable(SpecialResultMarker m) {\n    return m == SpecialResultMarker.NO_RESULT_MARKER\n        || m == SpecialResultMarker.NULL_RESULT_MARKER\n        || m instanceof SpecialResultMarker.ExceptionThrownMarker;\n}","typeGuard":"static boolean isEncodableMarker(Object v) {\n    return v == SpecialResultMarker.NO_RESULT_MARKER\n        || v == SpecialResultMarker.NULL_RESULT_MARKER\n        || v instanceof SpecialResultMarker.ExceptionThrownMarker;\n}","tryCatchPattern":"try {\n    codec.writeResult(result);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unexpected marker\")) {\n        // skip recording this result or fail with context\n    } else throw e;\n}","preventionTips":["Do not create ad-hoc SpecialResultMarker subclasses; use the two singletons and the exception marker","When adding a new marker kind, update both write and read switches in BinaryReplayCodec and bump VERSION"],"tags":["graalvm","replay-compilation","serialization","codec","marker"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}