Tencent/matrix · error · IllegalArgumentException
Field does not exists
Error message
Field <fieldName> does not exists
What it means
HahaHelper.fieldValue scans a heap-dump ClassInstance's field values for a field with the given name and throws IllegalArgumentException when no field matches. This means the analyzer expected an instance to have a named field (e.g. 'name', 'count', 'value') that is absent from the dumped class.
Solutions
- Check hasField(values, fieldName) before calling fieldValue and handle the missing case gracefully.
- Update Matrix/Haha to a version matching the Android version the dump was captured on.
- Re-capture the heap dump on a supported OS version.
- Log the instance's class name and available fields to diagnose the expected layout, then adjust the field-name constant.
Example fix
// before
String name = asString(fieldValue(values, "name"));
// after
String name = hasField(values, "name")
? asString(fieldValue(values, "name"))
: "<unknown>"; Defensive patterns
Strategy: validation
Validate before calling
if (!HahaHelper.hasField(values, fieldName)) { return fallback; } Try / catch
try { return fieldValue(values, "name"); } catch (IllegalArgumentException e) { return defaultValue; } Prevention
- Always call hasField before fieldValue
- Keep analyzer in sync with target OS String/class internals
- Log available fields when a lookup fails to aid diagnosis
When it happens
Trigger: Calling fieldValue with a field name that does not exist on the instance's class — e.g. reading 'value'/'count' from a String or wrapper class whose field layout differs across Android versions, or a renamed field when the class changed between OS versions.
Common situations: Analyzing dumps from Android versions where String internals changed (char[] value vs byte[] value, coder fields added); library updates renaming internal fields; parsing classes from a different JDK/ART than the analyzer expects.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Could not find char array in
- Unable to obtained scaled bitmap's dimensions
- Unexpected type for
- Unknown root type:
- Both of invoker and fieldName can not be null or nil.
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/11a451698ae4542b.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer/src/main/java/com/squareup/haha/perflib/HahaHelper.java:163
}
private static boolean isByteArray(Object value) {
return value instanceof ArrayInstance && ((ArrayInstance) value).getArrayType() == Type.BYTE;
}
public static List<ClassInstance.FieldValue> classInstanceValues(Instance instance) {
ClassInstance classInstance = (ClassInstance) instance;
return classInstance.getValues();
}
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public static <T> T fieldValue(List<ClassInstance.FieldValue> values, String fieldName) {
for (ClassInstance.FieldValue fieldValue : values) {
if (fieldValue.getField().getName().equals(fieldName)) {
return (T) fieldValue.getValue();
}
}
throw new IllegalArgumentException("Field " + fieldName + " does not exists");
}
public static boolean hasField(List<ClassInstance.FieldValue> values, String fieldName) {
for (ClassInstance.FieldValue fieldValue : values) {
if (fieldValue.getField().getName().equals(fieldName)) {
//noinspection unchecked
return true;
}
}
return false;
}
public static int getArrayInstanceLength(ArrayInstance instance) {
try {
final java.lang.reflect.Field mLengthField = ArrayInstance.class.getDeclaredField("mLength");
mLengthField.setAccessible(true);
return mLengthField.getInt(instance);
} catch (Throwable thr) {View on GitHub (pinned to 3b8293bd65)