{"record":{"id":"b99f41cf3d797dbd","repo":"oracle/graal","slug":"unsupported-type-s","errorCode":null,"errorMessage":"Unsupported type %s","messagePattern":"Unsupported type (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/truffle/BinaryOutput.java","lineNumber":303,"sourceCode":"            writeByte(CHAR);\n            writeChar((char) value);\n        } else if (value instanceof Integer) {\n            writeByte(INT);\n            writeInt((int) value);\n        } else if (value instanceof Long) {\n            writeByte(LONG);\n            writeLong((long) value);\n        } else if (value instanceof Float) {\n            writeByte(FLOAT);\n            writeFloat((float) value);\n        } else if (value instanceof Double) {\n            writeByte(DOUBLE);\n            writeDouble((double) value);\n        } else if (value instanceof String) {\n            writeByte(STRING);\n            writeUTF((String) value);\n        } else {\n            throw new IllegalArgumentException(String.format(\"Unsupported type %s\", value.getClass()));\n        }\n    }\n\n    /**\n     * Writes {@code len} bytes from the boolean {@code array} starting at offset {@code off}. The\n     * value {@code true} is written as the value {@code (byte)1}, the value {@code false} is\n     * written as the value {@code (byte)0}. The buffer position is incremented by {@code len}.\n     */\n    public final void write(boolean[] array, int off, int len) {\n        ensureBufferSize(0, len);\n        for (int i = 0, j = 0; i < len; i++, j++) {\n            tempDecodingBuffer[j] = (byte) (array[off + i] ? 1 : 0);\n        }\n        write(tempDecodingBuffer, 0, len);\n    }\n\n    /**\n     * Writes {@code len} shorts from the {@code array} starting at offset {@code off}. The buffer","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/truffle/BinaryOutput.java#L285-L321","documentation":"BinaryOutput.writeValue supports only a fixed set of boxed types — Boolean, Byte/Short/Integer-like integral boxes ending at LONG, Float, Double, and String (plus null/array handling elsewhere). Any other runtime type hits the final else and throws IllegalArgumentException(String.format(\"Unsupported type %s\", value.getClass())). The marshalled value protocol is intentionally minimal.","triggerScenarios":"Calling writeValue with an arbitrary object (e.g. a custom record, enum, Object holding a Class reference, or a boxed type outside the supported set such as Character/BigDecimal) that was not converted beforehand.","commonSituations":"Generic code path where an unexpected boxed value trickles into the marshalling layer; adding a new value kind to a protocol without extending both writer and reader; null-handling assumptions that route non-null unknown objects into writeValue.","solutions":["Convert the value to a supported primitive/String (or a handle) before writeValue.","Whitelist types at the call site with explicit instanceof branches mirroring writeValue's own dispatch.","Fail fast in your API: validate value types before entering the marshalling layer rather than relying on its terminal exception.","If you control the protocol, add a new tag on both BinaryOutput and BinaryInput sides consistently."],"exampleFix":"// before\nout.writeValue(maybeAnything);\n// after (explicit supported-type dispatch)\nif (v instanceof String s) out.writeValue(s);\nelse if (v instanceof Integer i) out.writeValue(i);\nelse throw new IllegalArgumentException(\"pre-validated: unsupported \" + v.getClass());","handlingStrategy":"type-guard","validationCode":"static boolean isMarshalableValue(Object v) {\n    return v == null || v instanceof Boolean || v instanceof Byte || v instanceof Short\n        || v instanceof Integer || v instanceof Long || v instanceof Float\n        || v instanceof Double || v instanceof String;\n}","typeGuard":"static boolean isMarshalableValue(Object v) {\n    return v == null || v instanceof Boolean || v instanceof Byte || v instanceof Short\n        || v instanceof Integer || v instanceof Long || v instanceof Float\n        || v instanceof Double || v instanceof String;\n}","tryCatchPattern":"try {\n    out.writeValue(v);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unsupported type\")) {\n        // convert v to String/primitive or obtain an object handle instead\n    }\n}","preventionTips":["Pre-validate with an instanceof whitelist mirroring writeValue's dispatch","Convert domain objects to primitives/Strings/handles before marshalling","Extend the tag protocol on both sides in lockstep if new types are needed"],"tags":["libgraal","truffle","marshalling","type-validation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}