{"record":{"id":"e66e5d7268534ff0","repo":"Tencent/matrix","slug":"unexpected-type-for","errorCode":null,"errorMessage":"Unexpected type for ","messagePattern":"Unexpected type for ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer/src/main/java/com/tencent/matrix/resource/analyzer/utils/ShortestPathFinder.java","lineNumber":285,"sourceCode":"                if (targetRefSet.isEmpty()) {\n                    break;\n                }\n            }\n\n            if (checkSeen(node)) {\n                continue;\n            }\n\n            if (node.instance instanceof RootObj) {\n                visitRootObj(node);\n            } else if (node.instance instanceof ClassObj) {\n                visitClassObj(node);\n            } else if (node.instance instanceof ClassInstance) {\n                visitClassInstance(node);\n            } else if (node.instance instanceof ArrayInstance) {\n                visitArrayInstance(node);\n            } else {\n                throw new IllegalStateException(\"Unexpected type for \" + node.instance);\n            }\n        }\n        return results;\n    }\n\n    private void clearState() {\n        toVisitQueue.clear();\n        toVisitIfNoPathQueue.clear();\n        toVisitSet.clear();\n        toVisitIfNoPathSet.clear();\n        visitedSet.clear();\n    }\n\n    private void enqueueGcRoots(Snapshot snapshot) {\n        for (RootObj rootObj : snapshot.getGCRoots()) {\n            switch (rootObj.getRootType()) {\n                case JAVA_LOCAL:\n                    Instance thread = HahaSpy.allocatingThread(rootObj);","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer/src/main/java/com/tencent/matrix/resource/analyzer/utils/ShortestPathFinder.java#L267-L303","documentation":"findPath dispatches each queued node by the concrete Instance type: ClassObj, ClassInstance, or ArrayInstance. If node.instance is none of these (an unknown/unexpected heap object type from the parser), the finder cannot visit it and throws IllegalStateException.","triggerScenarios":"The heap dump contains an Instance subtype the bundled Haha parser version does not model (e.g. a new dump format producing an unrecognized instance type) and findPath dequeues it.","commonSituations":"Analyzing hprof files from newer Android/ART versions with an older Haha parser; corrupted dumps yielding degenerate instance objects; mixing dump versions with an outdated Matrix analyzer.","solutions":["Update Matrix/Haha to a parser version matching the OS that produced the hprof.","Re-capture the heap dump on a supported device/OS.","Add a fallback branch that skips unknown instance types instead of aborting the whole search.","Validate the hprof (it should parse cleanly in MAT/Android Studio) to rule out corruption."],"exampleFix":"// before\n} else {\n    throw new IllegalStateException(\"Unexpected type for \" + node.instance);\n}\n// after\n} else {\n    continue; // skip unknown instance type, don't abort path search\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"boolean isKnownInstance(Instance i) { return i instanceof ClassObj || i instanceof ClassInstance || i instanceof ArrayInstance; }","tryCatchPattern":"try { result = finder.findPath(...); } catch (IllegalStateException e) { log.error(\"unsupported instance type in dump\", e); }","preventionTips":["Use a parser version matching the dump's OS/format","Sanity-check dumps in MAT/Android Studio before analysis","Skip unrecognized nodes rather than failing the entire search"],"tags":["heap-dump","hprof","type-mismatch","android"],"backgroundTag":"unsupported-operation","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"}