{"record":{"id":"38a856101564a5fc","repo":"Tencent/matrix","slug":"object-type-is-not-a-primitive-type","errorCode":null,"errorMessage":"OBJECT type is not a primitive type","messagePattern":"OBJECT type is not a primitive type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/hproflib/model/Type.java","lineNumber":76,"sourceCode":"    public int getSize(int idSize) {\n        return mSize != 0 ? mSize : idSize;\n    }\n\n    public int getTypeId() {\n        return mId;\n    }\n\n    public static String getClassNameOfPrimitiveArray(Type type) {\n        switch (type) {\n            case BOOLEAN: return \"boolean[]\";\n            case CHAR: return \"char[]\";\n            case FLOAT: return \"float[]\";\n            case DOUBLE: return \"double[]\";\n            case BYTE: return \"byte[]\";\n            case SHORT: return \"short[]\";\n            case INT: return \"int[]\";\n            case LONG: return \"long[]\";\n            default: throw new IllegalArgumentException(\"OBJECT type is not a primitive type\");\n        }\n    }\n}\n","sourceCodeStart":58,"sourceCodeEnd":80,"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/model/Type.java#L58-L80","documentation":"Type.getClassNameOfPrimitiveArray() maps a hprof basic type to its JVM array class name (e.g. int[]). The OBJECT type is a reference, not a primitive, so it has no primitive-array class name; requesting it throws IllegalArgumentException. This is a caller contract violation, not file corruption.","triggerScenarios":"Calling Type.getClassNameOfPrimitiveArray(Type.OBJECT) directly; misclassifying a field/array element as OBJECT when computing primitive array class names during hprof analysis.","commonSituations":"Custom analysis code over Matrix's hproflib that iterates all Type values including OBJECT; bugs in array-class inference where object arrays (which use class object IDs, not primitive values) are fed into the primitive-array helper.","solutions":["Guard the call: only invoke getClassNameOfPrimitiveArray for types other than OBJECT.","Handle object arrays separately using the array class object ID / class name from the class dump.","If iterating all types, skip OBJECT in the loop."],"exampleFix":"// before\nString name = Type.getClassNameOfPrimitiveArray(type);\n\n// after\nif (type == Type.OBJECT) {\n    // object arrays resolve via class object, not primitive mapping\n    return resolveObjectArrayClassName(classId);\n}\nString name = Type.getClassNameOfPrimitiveArray(type);","handlingStrategy":"type-guard","validationCode":"if (type == Type.OBJECT) { /* handle object arrays via class object */ }","typeGuard":"static boolean isPrimitive(Type t) {\n    return t != Type.OBJECT;\n}","tryCatchPattern":"try {\n    name = Type.getClassNameOfPrimitiveArray(type);\n} catch (IllegalArgumentException e) {\n    name = resolveObjectArrayClassName(classId);\n}","preventionTips":["Exclude Type.OBJECT when iterating basic types for array class names","Resolve object arrays through the class object ID, not the primitive map","Unit-test type-to-array-name mapping over all enum values"],"tags":["hprof","type-error","android","memory-analysis"],"backgroundTag":"invalid-enum-value","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"}