{"record":{"id":"74643bad52a590ac","repo":"oracle/graal","slug":"unexpected-kind","errorCode":null,"errorMessage":"Unexpected kind: ","messagePattern":"Unexpected kind: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/FrameRecordSerializer.java","lineNumber":335,"sourceCode":"        throw new NoSuchMethodException(\"%s %s.%s(%s)\".formatted(\n                        returnType.getName(), declaringClass.getName(), name, String.join(\", \", Arrays.stream(argTypes).map(Class::getName).toList())));\n    }\n\n    private Class<?> readClass(ClassLoader classLoader) throws IOException, ClassNotFoundException {\n        assert in != null;\n        int kind = in.readUnsignedByte();\n        return switch (kind) {\n            case 'I' -> int.class;\n            case 'Z' -> boolean.class;\n            case 'D' -> double.class;\n            case 'F' -> float.class;\n            case 'J' -> long.class;\n            case 'B' -> byte.class;\n            case 'C' -> char.class;\n            case 'S' -> short.class;\n            case 'V' -> void.class;\n            case 'L' -> Class.forName(readString(), false, classLoader);\n            default -> throw new IOException(\"Unexpected kind: \" + kind);\n        };\n    }\n\n    private String readString() throws IOException {\n        assert in != null;\n        int idx = in.readChar();\n        if ((idx & NEW_POOL_MASK) != 0) {\n            String value = in.readUTF();\n            idx = idx & POOL_IDX_MASK;\n            if (idx == stringPoolRead.size()) {\n                stringPoolRead.add(value);\n            } else {\n                stringPoolRead.set(idx, value);\n            }\n            return value;\n        } else {\n            assert idx <= MAX_POOL_IDX;\n            return stringPoolRead.get(idx);","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/FrameRecordSerializer.java#L317-L353","documentation":"Thrown as IOException by FrameRecordSerializer.readClass when the kind byte read from the stream matches none of 'I','Z','D','F','J','B','C','S','V','L'. Those single-letter codes encode the 9 primitive/void kinds plus 'L' for reference types (followed by a pooled class name); any other value means the reader is misaligned with the writer — i.e. stream corruption or an incompatible format version slipped past the header check.","triggerScenarios":"Deserializing a frame whose type descriptor bytes were truncated or shifted (partial write, bad offset); reading a payload whose frame layout came from a different (unrecognized) format version; a custom ObjectInput implementation returning garbage for readUnsignedByte.","commonSituations":"Payload corrupted in storage or transit; two ends of a continuation exchange built from different library versions; test harnesses feeding hand-built streams into deserialize.","solutions":["Regenerate the continuation payload from a known-good serialize() call on the same runtime and retry.","Add integrity protection (checksum/HMAC) around persisted continuation bytes so corruption is detected before deserialization.","Confirm producer and consumer run the identical org.graalvm.continuations version (the kind byte is inside the version-gated frame body).","Discard the payload on this IOException — the reader's cursor is desynchronized, so nothing after this point is trustworthy."],"exampleFix":"// before\nstore.write(serialize(cont)); // partial write on crash -> truncated stream\n...\nContinuation.deserialize(read(), loader);\n\n// after\n// write-then-atomic-rename plus CRC\nbyte[] blob = serialize(cont);\nstore.atomicWrite(\"cont.bin\", blob, crc32(blob));\nif (crc32(read()) != expectedCRC) throw new CorruptPayloadException();\nContinuation.deserialize(read(), loader);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Continuation.deserialize(bytes, loader); } catch (IOException e) { /* 'Unexpected kind: N' => stream misaligned/corrupt or version drift: discard payload */ }","preventionTips":["Add CRC/checksum validation around persisted continuation bytes.","Use atomic write-then-rename for payload files so partial writes never reach the reader.","Never re-serialize a payload that failed mid-read; regenerate from a live continuation."],"tags":["serialization","continuations","corrupt-stream","frame-format"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}