{"record":{"id":"a6a3f1cb5b58a59c","repo":"skylot/jadx","slug":"unsigned-byte-value-is-too-big","errorCode":null,"errorMessage":"Unsigned byte value is too big: ","messagePattern":"Unsigned byte value is too big: ","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/clsp/ClsSet.java","lineNumber":482,"sourceCode":"\t}\n\n\tprivate static String readString(DataInputStream in, int len) throws IOException {\n\t\tbyte[] bytes = new byte[len];\n\t\tint count = in.read(bytes);\n\t\twhile (count != len) {\n\t\t\tint res = in.read(bytes, count, len - count);\n\t\t\tif (res == -1) {\n\t\t\t\tthrow new IOException(\"String read error\");\n\t\t\t} else {\n\t\t\t\tcount += res;\n\t\t\t}\n\t\t}\n\t\treturn new String(bytes, STRING_CHARSET);\n\t}\n\n\tprivate static void writeUnsignedByte(DataOutputStream out, int value) throws IOException {\n\t\tif (value < 0 || value >= 0xFF) {\n\t\t\tthrow new JadxRuntimeException(\"Unsigned byte value is too big: \" + value);\n\t\t}\n\t\tout.writeByte(value);\n\t}\n\n\tprivate static int readUnsignedByte(DataInputStream in) throws IOException {\n\t\treturn ((int) in.readByte()) & 0xFF;\n\t}\n\n\tpublic int getClassesCount() {\n\t\treturn classes.length;\n\t}\n\n\tpublic void addToMap(Map<String, ClspClass> nameMap) {\n\t\tfor (ClspClass cls : classes) {\n\t\t\tnameMap.put(cls.getName(), cls);\n\t\t}\n\t}\n","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/clsp/ClsSet.java#L464-L500","documentation":"Thrown by ClsSet.writeUnsignedByte() when the value being written is negative or >= 255. This is a defensive programming check during .clst serialization. The unsigned-byte format slot can only hold values 0–254. Any caller passing a value outside that range is a bug in the writing code.","triggerScenarios":"Internal programming error where a string length, type list count, or other small value exceeds the single-byte capacity. Could be triggered indirectly by writeString() if the string is exactly 255 bytes (though writeString checks >= 255 first).","commonSituations":"Modifying ClsSet serialization logic and accidentally passing a value >= 255 or < 0 to writeUnsignedByte. Extremely long names or large counts overflowing the format.","solutions":["Check the caller of writeUnsignedByte — the value must be in [0, 254]. Add logging before the call to identify which field overflows.","If the value legitimately exceeds 254, switch the encoding to a wider type (e.g., writeShort) and update the corresponding reader.","Ensure string lengths are validated upstream in writeString before reaching this method."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// If you call writeUnsignedByte directly, validate first\nprivate static void safeWriteUnsignedByte(DataOutputStream out, int value) throws IOException {\n    if (value < 0 || value >= 0xFF) {\n        throw new IllegalArgumentException(\n            \"Value out of unsigned-byte range [0, 254]: \" + value);\n    }\n    out.writeByte(value);\n}","typeGuard":null,"tryCatchPattern":"try {\n    writeUnsignedByte(out, value);\n} catch (JadxRuntimeException e) {\n    logger.error(\"Value {} exceeds unsigned-byte format limit\", value, e);\n    // Switch to wider encoding or truncate the data set\n    throw e;\n}","preventionTips":["Always validate value ranges before calling writeUnsignedByte.","Ensure string lengths and counts are pre-checked upstream.","Log the offending value and context to diagnose which field overflows."],"tags":["clsp","serialization","format-limit","internal-bug"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}