{"record":{"id":"590af8b9c4932f11","repo":"skylot/jadx","slug":"copy-blocks-tree-failed-missing-block-for-connect","errorCode":null,"errorMessage":"Copy blocks tree failed. Missing block for connection: {}","messagePattern":"Copy blocks tree failed\\. Missing block for connection: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/blocks/BlockSplitter.java","lineNumber":235,"sourceCode":"\t\t\tBlockNode newBlock = startNewBlock(mth, block.getStartOffset());\n\t\t\tcopyBlockData(block, newBlock);\n\t\t\tcopyBlocks.add(newBlock);\n\t\t\tmap.put(block, newBlock);\n\t\t}\n\t\tfor (BlockNode block : blocks) {\n\t\t\tBlockNode newBlock = getNewBlock(block, map);\n\t\t\tfor (BlockNode successor : block.getSuccessors()) {\n\t\t\t\tBlockNode newSuccessor = getNewBlock(successor, map);\n\t\t\t\tBlockSplitter.connect(newBlock, newSuccessor);\n\t\t\t}\n\t\t}\n\t\treturn copyBlocks;\n\t}\n\n\tprivate static BlockNode getNewBlock(BlockNode block, Map<BlockNode, BlockNode> map) {\n\t\tBlockNode newBlock = map.get(block);\n\t\tif (newBlock == null) {\n\t\t\tthrow new JadxRuntimeException(\"Copy blocks tree failed. Missing block for connection: \" + block);\n\t\t}\n\t\treturn newBlock;\n\t}\n\n\tstatic void replaceTarget(BlockNode source, BlockNode oldTarget, BlockNode newTarget) {\n\t\tInsnNode lastInsn = BlockUtils.getLastInsn(source);\n\t\tif (lastInsn instanceof TargetInsnNode) {\n\t\t\t((TargetInsnNode) lastInsn).replaceTargetBlock(oldTarget, newTarget);\n\t\t}\n\t}\n\n\tprivate static void setupConnectionsFromJumps(MethodNode mth, Map<Integer, BlockNode> blocksMap) {\n\t\tfor (BlockNode block : mth.getBasicBlocks()) {\n\t\t\tfor (InsnNode insn : block.getInstructions()) {\n\t\t\t\tList<JumpInfo> jumps = insn.getAll(AType.JUMP);\n\t\t\t\tfor (JumpInfo jump : jumps) {\n\t\t\t\t\tBlockNode srcBlock = getBlock(jump.getSrc(), blocksMap);\n\t\t\t\t\tBlockNode thisBlock = getBlock(jump.getDest(), blocksMap);","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/blocks/BlockSplitter.java#L217-L253","documentation":"Thrown when copying a block tree (used for method duplication in JSR resolution and inlining). The copy process builds a map from original blocks to new blocks, then reconnects successors. If a successor block has no entry in the map, the tree structure is incomplete and the copy cannot proceed.","triggerScenarios":"During copyBlocksTree, getNewBlock(successor, map) returns null because the successor BlockNode was not included in the initial map population. This means the source block graph has a successor that wasn't registered for copying.","commonSituations":"Internal inconsistency in the block graph during duplication; a block was added or modified between map creation and successor traversal; typically triggered during JSR/RET resolution or method inlining on complex control flow.","solutions":["Update jadx — block tree copy logic is periodically refined","Report the APK and failing method as a jadx issue with the full stack trace","Try with --no-inline-anonymous or similar flags that reduce code duplication","Exclude the problematic class if the rest of the APK decompiles fine"],"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(\"Copy blocks tree failed\")) {\n        LOG.warn(\"Block tree copy inconsistency, trying per-class decompilation\");\n        for (ClassNode cls : jadxDecompiler.getClasses()) {\n            try {\n                jadxDecompiler.decompileClass(cls);\n            } catch (JadxRuntimeException ex) {\n                LOG.warn(\"Skipped: {}\", cls.getFullName());\n            }\n        }\n    } else {\n        throw e;\n    }\n}","preventionTips":["Keep jadx updated — block tree copy logic is periodically refined","Try disabling inlining passes if available (e.g., --no-inline-anonymous)","Report the APK as a jadx issue with the full stack trace","Decompile classes individually to isolate the trigger"],"tags":["block-processing","tree-copy","control-flow","decompiler"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}