Tencent/matrix · error · IllegalStateException
Unexpected type for
Error message
Unexpected type for
What it means
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.
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.
Example fix
// before
} else {
throw new IllegalStateException("Unexpected type for " + node.instance);
}
// after
} else {
continue; // skip unknown instance type, don't abort path search
} Defensive patterns
Strategy: try-catch
Type guard
boolean isKnownInstance(Instance i) { return i instanceof ClassObj || i instanceof ClassInstance || i instanceof ArrayInstance; } Try / catch
try { result = finder.findPath(...); } catch (IllegalStateException e) { log.error("unsupported instance type in dump", e); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unable to obtained scaled bitmap's dimensions
- Could not find char array in
- Field does not exists
- Unknown root type:
- visit bmp instance failed, lost type def of typeId:
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/e66e5d7268534ff0.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-analyzer/src/main/java/com/tencent/matrix/resource/analyzer/utils/ShortestPathFinder.java:285
if (targetRefSet.isEmpty()) {
break;
}
}
if (checkSeen(node)) {
continue;
}
if (node.instance instanceof RootObj) {
visitRootObj(node);
} else if (node.instance instanceof ClassObj) {
visitClassObj(node);
} else if (node.instance instanceof ClassInstance) {
visitClassInstance(node);
} else if (node.instance instanceof ArrayInstance) {
visitArrayInstance(node);
} else {
throw new IllegalStateException("Unexpected type for " + node.instance);
}
}
return results;
}
private void clearState() {
toVisitQueue.clear();
toVisitIfNoPathQueue.clear();
toVisitSet.clear();
toVisitIfNoPathSet.clear();
visitedSet.clear();
}
private void enqueueGcRoots(Snapshot snapshot) {
for (RootObj rootObj : snapshot.getGCRoots()) {
switch (rootObj.getRootType()) {
case JAVA_LOCAL:
Instance thread = HahaSpy.allocatingThread(rootObj);View on GitHub (pinned to 3b8293bd65)