{"record":{"id":"d933b723ef5cf038","repo":"Tencent/matrix","slug":"accept-class-failed-lost-type-def-of-typeid","errorCode":null,"errorMessage":"accept class failed, lost type def of typeId: ","messagePattern":"accept class failed, lost type def of typeId: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/hproflib/HprofReader.java","lineNumber":309,"sourceCode":"\n        //  Skip over the constant pool\n        int numEntries = IOUtil.readBEShort(mStreamIn);\n        bytesRead += 2;\n        for (int i = 0; i < numEntries; ++i) {\n            IOUtil.skip(mStreamIn, 2);\n            bytesRead += 2 + skipValue();\n        }\n\n        //  Static fields\n        numEntries = IOUtil.readBEShort(mStreamIn);\n        Field[] staticFields = new Field[numEntries];\n        bytesRead += 2;\n        for (int i = 0; i < numEntries; ++i) {\n            final ID nameId = IOUtil.readID(mStreamIn, mIdSize);\n            final int typeId = mStreamIn.read();\n            final Type type = Type.getType(typeId);\n            if (type == null) {\n                throw new IllegalStateException(\"accept class failed, lost type def of typeId: \" + typeId);\n            }\n            final Object staticValue = IOUtil.readValue(mStreamIn, type, mIdSize);\n            staticFields[i] = new Field(typeId, nameId, staticValue);\n            bytesRead += mIdSize + 1 + type.getSize(mIdSize);\n        }\n\n        //  Instance fields\n        numEntries = IOUtil.readBEShort(mStreamIn);\n        final Field[] instanceFields = new Field[numEntries];\n        bytesRead += 2;\n        for (int i = 0; i < numEntries; i++) {\n            final ID nameId = IOUtil.readID(mStreamIn, mIdSize);\n            final int typeId = mStreamIn.read();\n            instanceFields[i] = new Field(typeId, nameId, null);\n            bytesRead += mIdSize + 1;\n        }\n\n        hdv.visitHeapDumpClass(id, stackSerialNumber, superClassId, classLoaderId, instanceSize, staticFields, instanceFields);","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/hproflib/HprofReader.java#L291-L327","documentation":"When processing a CLASS DUMP record's static fields, HprofReader.acceptClassDump() resolves each field's value type via Type.getType(typeId). If the dump contains a static field type byte that is not one of the known hprof types (object/boolean/char/float/double/byte/short/int/long), Type.getType returns null and the reader throws IllegalStateException instead of consuming an unknown-size value from the stream.","triggerScenarios":"acceptClassDump() reads a static field whose type byte is invalid (not 2,4-8) — a corrupted dump or a stream desynchronized by an earlier parse error.","commonSituations":"Truncated/corrupted hprof transfer off-device; byte-level desynchronization after an earlier unknown tag; hprof post-processed by third-party tools.","solutions":["Re-capture the hprof from the device to replace a corrupted dump.","Confirm the whole file transferred intact (compare checksums between device pull and server copy).","Fix upstream parse errors that may have shifted the stream position before the class dump.","Catch IllegalStateException during parsing and mark the dump invalid."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (file.length() == 0 || !file.canRead()) {\n    throw new IOException(\"hprof missing or unreadable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    hprofReader.accept(visitor);\n} catch (IllegalStateException e) {\n    Log.e(TAG, \"class dump parse failed; dump may be corrupt\", e);\n}","preventionTips":["Confirm checksums between device pull and server copy of the hprof.","Investigate upstream parse errors before blaming the record itself.","Re-capture dumps rather than re-parsing corrupted files."],"tags":["android","hprof","parser","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}