{"record":{"id":"491255d776b3dc3b","repo":"skylot/jadx","slug":"can-t-find-block-by-offset-in-list","errorCode":null,"errorMessage":"Can't find block by offset: {} in list {}","messagePattern":"Can't find block by offset: (.+?) in list (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/utils/BlockUtils.java","lineNumber":57,"sourceCode":"import jadx.core.dex.regions.conditions.IfCondition;\nimport jadx.core.dex.trycatch.CatchAttr;\nimport jadx.core.dex.trycatch.ExceptionHandler;\nimport jadx.core.utils.blocks.BlockSet;\nimport jadx.core.utils.blocks.DFSIteration;\nimport jadx.core.utils.exceptions.JadxRuntimeException;\n\npublic class BlockUtils {\n\n\tprivate BlockUtils() {\n\t}\n\n\tpublic static BlockNode getBlockByOffset(int offset, Iterable<BlockNode> casesBlocks) {\n\t\tfor (BlockNode block : casesBlocks) {\n\t\t\tif (block.getStartOffset() == offset) {\n\t\t\t\treturn block;\n\t\t\t}\n\t\t}\n\t\tthrow new JadxRuntimeException(\"Can't find block by offset: \"\n\t\t\t\t+ InsnUtils.formatOffset(offset)\n\t\t\t\t+ \" in list \" + casesBlocks);\n\t}\n\n\tpublic static BlockNode selectOther(BlockNode node, List<BlockNode> blocks) {\n\t\tList<BlockNode> list = blocks;\n\t\tif (list.size() > 2) {\n\t\t\tlist = cleanBlockList(list);\n\t\t}\n\t\tif (list.size() != 2) {\n\t\t\tthrow new JadxRuntimeException(\"Incorrect nodes count for selectOther: \" + node + \" in \" + list);\n\t\t}\n\t\tBlockNode first = list.get(0);\n\t\tif (first != node) {\n\t\t\treturn first;\n\t\t} else {\n\t\t\treturn list.get(1);\n\t\t}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/utils/BlockUtils.java#L39-L75","documentation":"Thrown by BlockUtils.getBlockByOffset when no block in the supplied casesBlocks iterable has a start offset equal to the requested offset. It is a linear-scan lookup helper used by IfNode/SwitchInsn to resolve branch targets against the method's successors list during block-graph construction. Failure means a branch/case target offset is not present in the expected block list.","triggerScenarios":"Building the block graph for an if-instruction (IfNode) or a switch (SwitchInsn) where the branch target offset does not match the startOffset() of any block in the instruction's successors list - e.g. a target that points into the middle of another block, or successors that were not collected correctly.","commonSituations":"Malformed DEX with branch targets into the middle of instructions, multi-dex inputs with mis-aligned code offsets, or a jadx bug in successor collection. Rare on valid bytecode; common on hand-edited or packed inputs.","solutions":["Update jadx; offset/successor collection is fixed regularly.","Report the input plus the offset and block list from the message.","Skip the affected class and continue the batch.","Catch JadxRuntimeException per class/method when using jadx as a library."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    BlockNode b = BlockUtils.getBlockByOffset(off, blocks);\n} catch (JadxRuntimeException e) {\n    LOG.warn(\"offset {} not in block list, skipping\", off, e);\n}","preventionTips":["Update jadx; branch-target/successor collection fixes land regularly.","Report the input with the offset and list from the message.","Catch per method to keep batch decompilation resilient."],"tags":["decompiler","blocks","control-flow","branches","malformed-bytecode"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}