{"record":{"id":"acf64a0efbb7a022","repo":"skylot/jadx","slug":"same-handlers-in-try-block","errorCode":null,"errorMessage":"Same handlers in try block: {}","messagePattern":"Same handlers in try block: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/blocks/BlockExceptionHandler.java","lineNumber":615,"sourceCode":"\t\t\t\treturn false;\n\t\t\t}\n\t\t\tresultHandler.addCatchTypes(mth, handler.getCatchTypes());\n\t\t\thandler.markForRemove();\n\t\t\treturn true;\n\t\t});\n\t\treturn true;\n\t}\n\n\tprivate static void sortHandlers(MethodNode mth, List<TryCatchBlockAttr> tryBlocks) {\n\t\tTypeCompare typeCompare = mth.root().getTypeCompare();\n\t\tComparator<ArgType> comparator = typeCompare.getReversedComparator();\n\t\tfor (TryCatchBlockAttr tryBlock : tryBlocks) {\n\t\t\tfor (ExceptionHandler handler : tryBlock.getHandlers()) {\n\t\t\t\thandler.getCatchTypes().sort((first, second) -> compareByTypeAndName(comparator, first, second));\n\t\t\t}\n\t\t\ttryBlock.getHandlers().sort((first, second) -> {\n\t\t\t\tif (first.equals(second)) {\n\t\t\t\t\tthrow new JadxRuntimeException(\"Same handlers in try block: \" + tryBlock);\n\t\t\t\t}\n\t\t\t\tif (first.isCatchAll()) {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tif (second.isCatchAll()) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\treturn compareByTypeAndName(comparator,\n\t\t\t\t\t\tListUtils.first(first.getCatchTypes()), ListUtils.first(second.getCatchTypes()));\n\t\t\t});\n\t\t}\n\t}\n\n\t@SuppressWarnings(\"ComparatorResultComparison\")\n\tprivate static int compareByTypeAndName(Comparator<ArgType> comparator, ClassInfo first, ClassInfo second) {\n\t\tint r = comparator.compare(first.getType(), second.getType());\n\t\tif (r == -2) {\n\t\t\t// on conflict sort by name","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/blocks/BlockExceptionHandler.java#L597-L633","documentation":"Thrown while sorting exception handlers within a try block. If two ExceptionHandler objects compare as equal via .equals(), the sort comparator throws. Duplicate handlers in a try block indicate either a bytecode production bug or intentional obfuscation that duplicates catch clauses.","triggerScenarios":"During sortHandlers, the comparator encounters two handlers in tryBlock.getHandlers() that are .equals()-equal. Since the comparator is called by List.sort, this means the handler list contains true duplicates.","commonSituations":"Obfuscators that duplicate exception handler entries to confuse analysis; DEX files produced by bytecode manipulation libraries (ASM, etc.) with bugs; manual DEX editing or merging tools that duplicate catch entries.","solutions":["Update jadx — newer versions may deduplicate handlers before sorting","Report the APK as a jadx issue — duplicate handlers are a clear edge case worth handling gracefully","Verify the DEX file with baksmali to confirm duplicate handlers exist in the raw bytecode","Exclude the affected class if only partial decompilation is 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(\"Same handlers in try block\")) {\n        LOG.warn(\"Duplicate exception handlers detected, skipping problematic class\");\n        // Use per-class loop to continue past the problematic class\n    } else {\n        throw e;\n    }\n}","preventionTips":["Verify DEX exception tables with baksmali to check for duplicate handler entries","Keep jadx updated — handler deduplication may be added in future versions","Report the APK as a jadx issue since duplicate handlers are a clear edge case","Decompile classes individually to isolate the trigger"],"tags":["try-catch","exception-handling","duplicate-handlers","obfuscation","decompiler"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}