{"record":{"id":"000ea1dc9af44743","repo":"skylot/jadx","slug":"string-is-too-long","errorCode":null,"errorMessage":"String is too long: ","messagePattern":"String is too long: ","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/clsp/ClsSet.java","lineNumber":455,"sourceCode":"\t\t\t\treturn classes[in.readInt()].getClsType();\n\n\t\t\tcase ARRAY:\n\t\t\t\treturn ArgType.array(Objects.requireNonNull(readArgType(in)));\n\n\t\t\tcase PRIMITIVE:\n\t\t\t\tchar shortName = (char) in.readByte();\n\t\t\t\treturn ArgType.parse(shortName);\n\n\t\t\tdefault:\n\t\t\t\tthrow new JadxRuntimeException(\"Unsupported Arg Type: \" + ordinal);\n\t\t}\n\t}\n\n\tprivate static void writeString(DataOutputStream out, String name) throws IOException {\n\t\tbyte[] bytes = name.getBytes(STRING_CHARSET);\n\t\tint len = bytes.length;\n\t\tif (len >= 0xFF) {\n\t\t\tthrow new JadxRuntimeException(\"String is too long: \" + name);\n\t\t}\n\t\twriteUnsignedByte(out, bytes.length);\n\t\tout.write(bytes);\n\t}\n\n\tprivate static String readString(DataInputStream in) throws IOException {\n\t\tint len = readUnsignedByte(in);\n\t\treturn readString(in, len);\n\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 {","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/clsp/ClsSet.java#L437-L473","documentation":"Thrown by ClsSet.writeString() when a string being serialized to the .clst file exceeds 254 bytes in STRING_CHARSET encoding. The binary format uses a single unsigned byte for the length prefix (writeUnsignedByte), so it cannot represent lengths of 255 or greater. This is a format limitation, not a logic error.","triggerScenarios":"Calling ClsSet.save() or any codepath that writes a class name, type variable name, or other string whose encoded byte length is >= 255. Most common with extremely long obfuscated class names or deeply nested generic type signatures.","commonSituations":"Generating a custom .clst classpath that includes heavily obfuscated app classes with very long names. Processing a classpath with generated/templated class names that exceed the byte limit.","solutions":["Shorten or rename the offending class/type string so its encoded length stays under 255 bytes.","If you control the format, extend the length encoding to use two bytes (modify writeString/readString and writeUnsignedByte) — but this is a breaking format change requiring all readers to be updated.","Exclude the offending classes from the ClsSet export and document the 254-byte name limit."],"exampleFix":"// before\n//   writeString uses single-byte length, fails at >= 255 bytes\n// after: extend to unsigned short (breaking format change)\n//   private static void writeString(DataOutputStream out, String name) {\n//       byte[] bytes = name.getBytes(STRING_CHARSET);\n//       out.writeShort(bytes.length);\n//       out.write(bytes);\n//   }","handlingStrategy":"validation","validationCode":"// Before exporting a ClsSet, validate string lengths\nprivate static void validateStringForExport(String name) {\n    byte[] bytes = name.getBytes(STRING_CHARSET);\n    if (bytes.length >= 0xFF) {\n        throw new IllegalArgumentException(\n            \"Class/type name too long for .clst format (max 254 bytes): \" + name);\n    }\n}\n// Call before ClsSet.save() for each class name and type variable","typeGuard":null,"tryCatchPattern":"try {\n    clsSet.save(outputStream);\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().startsWith(\"String is too long\")) {\n        // Identify and shorten the offending name\n        logger.error(\"Class name exceeds 254-byte format limit. Rename or exclude it.\", e);\n    }\n    throw e;\n}","preventionTips":["Keep class and type names under 254 bytes when generating custom classpath sets.","Validate names before exporting rather than relying on the runtime check."],"tags":["clsp","serialization","format-limit","classpath"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}