{"record":{"id":"cfad2a73b55bc7c0","repo":"oracle/graal","slug":"cannot-serialize-result-marker-instance","errorCode":null,"errorMessage":"Cannot serialize result marker ${instance}","messagePattern":"Cannot serialize result marker (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/JsonReplayCodec.java","lineNumber":517,"sourceCode":"        }\n\n        @Override\n        public String tag() {\n            return \"marker\";\n        }\n\n        @Override\n        public void serialize(Object instance, JsonBuilder.ObjectBuilder objectBuilder, RecursiveSerializer serializer) throws IOException {\n            String type;\n            if (instance == SpecialResultMarker.NO_RESULT_MARKER) {\n                type = \"noResult\";\n            } else if (instance == SpecialResultMarker.NULL_RESULT_MARKER) {\n                type = \"null\";\n            } else if (instance instanceof SpecialResultMarker.ExceptionThrownMarker thrownMarker) {\n                type = \"exception\";\n                serializer.serialize(thrownMarker.getThrown(), objectBuilder.append(\"throwable\"));\n            } else {\n                throw new IllegalArgumentException(\"Cannot serialize result marker \" + instance);\n            }\n            objectBuilder.append(\"type\", type);\n        }\n\n        @Override\n        public Object deserialize(EconomicMap<String, Object> json, RecursiveDeserializer deserializer, CompilationProxies.ProxyFactory proxyFactory) throws DeserializationException {\n            switch ((String) json.get(\"type\")) {\n                case \"noResult\" -> {\n                    return SpecialResultMarker.NO_RESULT_MARKER;\n                }\n                case \"null\" -> {\n                    return SpecialResultMarker.NULL_RESULT_MARKER;\n                }\n                case \"exception\" -> {\n                    return new SpecialResultMarker.ExceptionThrownMarker((Throwable) deserializer.deserialize(json.get(\"throwable\"), proxyFactory));\n                }\n                case null, default -> throw new DeserializationException(this, json, \"Invalid marker type.\");\n            }","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/JsonReplayCodec.java#L499-L535","documentation":"ResultMarkerSerializer serializes SpecialResultMarker values that indicate what a recorded method call produced: NO_RESULT_MARKER, NULL_RESULT_MARKER, or ExceptionThrownMarker. Serialize() throws IllegalArgumentException when the instance is none of these — an unrecognized result-marker subtype reached the codec.","triggerScenarios":"A new SpecialResultMarker subtype is introduced (e.g. to encode 'result elided by filter' or lazy results) and the serializer switch is not updated; or a corrupted/proxied marker object of the wrong class is passed during serialization.","commonSituations":"GraalVM version drift where the recording side produces a marker type the serializing side cannot name; custom OperationRecorder implementations returning ad-hoc marker objects.","solutions":["Check instance.getClass() in a debugger to identify the unknown marker subtype","Add a branch to serialize() plus the mirror 'type' case in deserialize() in JsonReplayCodec.java:517","Re-record the replay file with the build you serialize on so marker types match"],"exampleFix":"// before\nelse { throw new IllegalArgumentException(\"Cannot serialize result marker \" + instance); }\n// after\nelse if (instance instanceof SpecialResultMarker.MyMarker m) {\n    type = \"myMarker\";\n    serializer.serialize(m.payload(), objectBuilder.append(\"payload\"));\n}\nelse { throw new IllegalArgumentException(\"Cannot serialize result marker \" + instance); }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isSupportedResultMarker(Object m) {\n    return m == SpecialResultMarker.NO_RESULT_MARKER\n        || m == SpecialResultMarker.NULL_RESULT_MARKER\n        || m instanceof SpecialResultMarker.ExceptionThrownMarker;\n}","tryCatchPattern":null,"preventionTips":["When adding a SpecialResultMarker subtype, update both serialize and deserialize branches and the type strings together","Unit-test the full marker set round trip through the codec"],"tags":["graalvm","replay","serialization","result-marker"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}