Tencent/matrix · error · IllegalArgumentException

OBJECT type is not a primitive type

Error message

OBJECT type is not a primitive type

What it means

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.

Solutions

  1. Guard the call: only invoke getClassNameOfPrimitiveArray for types other than OBJECT.
  2. Handle object arrays separately using the array class object ID / class name from the class dump.
  3. If iterating all types, skip OBJECT in the loop.

Example fix

// before
String name = Type.getClassNameOfPrimitiveArray(type);

// after
if (type == Type.OBJECT) {
    // object arrays resolve via class object, not primitive mapping
    return resolveObjectArrayClassName(classId);
}
String name = Type.getClassNameOfPrimitiveArray(type);
Defensive patterns

Strategy: type-guard

Validate before calling

if (type == Type.OBJECT) { /* handle object arrays via class object */ }

Type guard

static boolean isPrimitive(Type t) {
    return t != Type.OBJECT;
}

Try / catch

try {
    name = Type.getClassNameOfPrimitiveArray(type);
} catch (IllegalArgumentException e) {
    name = resolveObjectArrayClassName(classId);
}

Prevention

When it happens

Trigger: Calling Type.getClassNameOfPrimitiveArray(Type.OBJECT) directly; misclassifying a field/array element as OBJECT when computing primitive array class names during hprof analysis.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/38a856101564a5fc. Report an issue: GitHub.

Appendix: source

Thrown at matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/hproflib/model/Type.java:76

    public int getSize(int idSize) {
        return mSize != 0 ? mSize : idSize;
    }

    public int getTypeId() {
        return mId;
    }

    public static String getClassNameOfPrimitiveArray(Type type) {
        switch (type) {
            case BOOLEAN: return "boolean[]";
            case CHAR: return "char[]";
            case FLOAT: return "float[]";
            case DOUBLE: return "double[]";
            case BYTE: return "byte[]";
            case SHORT: return "short[]";
            case INT: return "int[]";
            case LONG: return "long[]";
            default: throw new IllegalArgumentException("OBJECT type is not a primitive type");
        }
    }
}

View on GitHub (pinned to 3b8293bd65)