{"record":{"id":"11a451698ae4542b","repo":"Tencent/matrix","slug":"field-fieldname-does-not-exists","errorCode":null,"errorMessage":"Field <fieldName> does not exists","messagePattern":"Field <fieldName> does not exists","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer/src/main/java/com/squareup/haha/perflib/HahaHelper.java","lineNumber":163,"sourceCode":"    }\n\n    private static boolean isByteArray(Object value) {\n        return value instanceof ArrayInstance && ((ArrayInstance) value).getArrayType() == Type.BYTE;\n    }\n\n    public static List<ClassInstance.FieldValue> classInstanceValues(Instance instance) {\n        ClassInstance classInstance = (ClassInstance) instance;\n        return classInstance.getValues();\n    }\n\n    @SuppressWarnings({\"unchecked\", \"TypeParameterUnusedInFormals\"})\n    public static <T> T fieldValue(List<ClassInstance.FieldValue> values, String fieldName) {\n        for (ClassInstance.FieldValue fieldValue : values) {\n            if (fieldValue.getField().getName().equals(fieldName)) {\n                return (T) fieldValue.getValue();\n            }\n        }\n        throw new IllegalArgumentException(\"Field \" + fieldName + \" does not exists\");\n    }\n\n    public static boolean hasField(List<ClassInstance.FieldValue> values, String fieldName) {\n        for (ClassInstance.FieldValue fieldValue : values) {\n            if (fieldValue.getField().getName().equals(fieldName)) {\n                //noinspection unchecked\n                return true;\n            }\n        }\n        return false;\n    }\n\n    public static int getArrayInstanceLength(ArrayInstance instance) {\n        try {\n            final java.lang.reflect.Field mLengthField = ArrayInstance.class.getDeclaredField(\"mLength\");\n            mLengthField.setAccessible(true);\n            return mLengthField.getInt(instance);\n        } catch (Throwable thr) {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer/src/main/java/com/squareup/haha/perflib/HahaHelper.java#L145-L181","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nString name = asString(fieldValue(values, \"name\"));\n// after\nString name = hasField(values, \"name\")\n        ? asString(fieldValue(values, \"name\"))\n        : \"<unknown>\";","handlingStrategy":"validation","validationCode":"if (!HahaHelper.hasField(values, fieldName)) { return fallback; }","typeGuard":null,"tryCatchPattern":"try { return fieldValue(values, \"name\"); } catch (IllegalArgumentException e) { return defaultValue; }","preventionTips":["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"],"tags":["hprof","heap-dump","reflection","android"],"backgroundTag":"schema-validation-failed","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"}