{"record":{"id":"cec1cba889306cbe","repo":"skylot/jadx","slug":"failed-to-find-top-block-for-try-catch-from","errorCode":null,"errorMessage":"Failed to find top block for try-catch from: {}","messagePattern":"Failed to find top block for try-catch from: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/blocks/BlockExceptionHandler.java","lineNumber":451,"sourceCode":"\t}\n\n\tprivate static BlockNode searchTopBlock(MethodNode mth, List<BlockNode> blocks) {\n\t\tBlockNode top = BlockUtils.getTopBlock(blocks);\n\t\tif (top != null) {\n\t\t\treturn adjustTopBlock(top);\n\t\t}\n\t\tBlockNode topDom = BlockUtils.getCommonDominator(mth, blocks);\n\t\tif (topDom != null) {\n\t\t\t// dominator always return one up block if blocks already contains dominator, use successor instead\n\t\t\tif (topDom.getSuccessors().size() == 1) {\n\t\t\t\tBlockNode upBlock = topDom.getSuccessors().get(0);\n\t\t\t\tif (blocks.contains(upBlock)) {\n\t\t\t\t\treturn upBlock;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn adjustTopBlock(topDom);\n\t\t}\n\t\tthrow new JadxRuntimeException(\"Failed to find top block for try-catch from: \" + blocks);\n\t}\n\n\tprivate static BlockNode adjustTopBlock(BlockNode topBlock) {\n\t\tif (topBlock.getSuccessors().size() == 1 && !topBlock.contains(AType.EXC_CATCH)) {\n\t\t\t// top block can be lifted by other exception handlers included in blocks list, trying to undo that\n\t\t\treturn topBlock.getSuccessors().get(0);\n\t\t}\n\t\treturn topBlock;\n\t}\n\n\t@Nullable\n\tprivate static BlockNode searchBottomBlock(MethodNode mth, List<BlockNode> blocks) {\n\t\t// search common post-dominator block inside input set\n\t\tBlockNode bottom = BlockUtils.getBottomBlock(blocks);\n\t\tif (bottom != null) {\n\t\t\treturn bottom;\n\t\t}\n\t\t// not found -> blocks don't have same dominator","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/blocks/BlockExceptionHandler.java#L433-L469","documentation":"Thrown when searching for the top block of a try-catch region. The algorithm computes the common dominator of all blocks in the try scope. If the common dominator is null and successor-based adjustments don't yield a valid top block, the control flow graph structure is inconsistent and the try-catch region cannot be anchored.","triggerScenarios":"BlockUtils.getCommonDominator returns null for the blocks in a try-catch scope, and the successor adjustment path (adjustTopBlock) is never reached because topDom itself is null. This means no single block dominates all blocks in the try region.","commonSituations":"Unusual CFG shapes produced by obfuscators that merge or split exception regions; try-catch blocks where the handler blocks are unreachable or have no predecessors; CFG inconsistencies from earlier block-processing passes.","solutions":["Update jadx — dominator and try-catch analysis are frequently improved","Report the APK and failing method as a jadx issue","Try decompiling with --fallback mode for the problematic class to get raw output","Exclude the problematic class from decompilation if only specific classes are needed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    jadxDecompiler.load();\n    jadxDecompiler.save();\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().contains(\"Failed to find top block for try-catch\")) {\n        LOG.warn(\"Try-catch dominator issue, retrying individual classes\");\n        for (ClassNode cls : jadxDecompiler.getClasses()) {\n            try {\n                jadxDecompiler.decompileClass(cls);\n            } catch (JadxRuntimeException ex) {\n                LOG.warn(\"Skipped problematic class: {}\", cls.getFullName());\n            }\n        }\n    } else {\n        throw e;\n    }\n}","preventionTips":["Keep jadx updated — dominator and try-catch analysis improve frequently","Decompile classes individually to isolate which class has the dominator issue","Report the APK as a jadx issue for investigation","Try --fallback mode for affected classes"],"tags":["try-catch","dominator","block-processing","control-flow","decompiler"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}