{"record":{"id":"6af5ae839ab10c3d","repo":"pxb1988/dex2jar","slug":"can-t-merge-a-and-b","errorCode":null,"errorMessage":"Can't merge ${a} and ${b}","messagePattern":"Can't merge (.+?) and (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dex-ir/src/main/java/com/googlecode/dex2jar/ir/TypeClass.java","lineNumber":126,"sourceCode":"            } else if (clz.fixed) {\n                return clz;\n            } else { // both not fixed\n                return merge0(thizCls, clz);\n            }\n        }\n    }\n\n    /**\n     * X     ZIL   ZIFL ZIF  ZI  IF\n     * ZIL   X     ZIL  ZI   ZI  I\n     * ZIFL  ZIL   X    ZIF  ZI  IF\n     * ZIF   ZI    ZIF  X    ZI  IF\n     * ZI    ZI    ZI   ZI   X   I\n     * IF    I     IF   IF   I   X\n     */\n    private static TypeClass merge0(TypeClass a, TypeClass b) {\n        if (a == JD || b == JD) {\n            throw new RuntimeException(\"Can't merge \" + a + \" and \" + b);\n        }\n        switch (a) {\n            case ZIL:\n                switch (b) {\n                    case ZIFL:\n                        return ZIL;\n                    case IF:\n                        return INT;\n                    case ZIF:\n                    case ZI:\n                        return ZI;\n                    default:\n                }\n            case ZIFL:\n                return b;\n            case IF:\n                switch (b) {\n                    case ZIL:","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-ir/src/main/java/com/googlecode/dex2jar/ir/TypeClass.java#L108-L144","documentation":"TypeClass represents value-type abstractions (zero/one/boolean, int/float, long, etc.) in dex2jar's IR. merge0 computes the least upper bound of two type classes; if either operand is JD (the 'double' class, which cannot combine with any other), no sensible result exists and the library throws this RuntimeException. It signals that the type-inference pass encountered two conflicting type sets during local variable merging.","triggerScenarios":"Calling TypeClass.merge (or merge0 directly) with one argument being TypeClass.JD while the other is any type class that yields no entry in the merge table (e.g. merging a double-typed value with an int/float/object value).","commonSituations":"Deobfuscating or translating malicious/obfuscated DEX where the same register is written with a double in one branch and a different type in another; bugs in custom transformers that assign types inconsistently before Cfg/type analysis.","solutions":["Inspect the IrMethod locals and fix the pass that assigned double (JD) to a register used as another type","Re-run on non-obfuscated DEX to confirm the input is the cause; preprocess with a dex deobfuscator","If intentional, extend merge0's table or catch RuntimeException around the transform pipeline","Report the input DEX as a dex2jar translation bug with the failing method"],"exampleFix":"// before (library)\nif (a == JD || b == JD) {\n    throw new RuntimeException(\"Can't merge \" + a + \" and \" + b);\n}\n// after (caller guard)\nTypeClass m;\ntry { m = TypeClass.merge(a, b); }\ncatch (RuntimeException e) { m = TypeClass.UNKNOWN; }","handlingStrategy":"try-catch","validationCode":"if (a == TypeClass.JD || b == TypeClass.JD) {\n    throw new IllegalArgumentException(\"cannot merge double class with \" + a + \"/\" + b);\n}\nTypeClass merged = TypeClass.merge(a, b);","typeGuard":"boolean mergeable(TypeClass t) { return t != TypeClass.JD; }","tryCatchPattern":"try {\n    merged = TypeClass.merge(a, b);\n} catch (RuntimeException e) {\n    if (!e.getMessage().startsWith(\"Can't merge \")) throw e;\n    merged = TypeClass.UNKNOWN; // or re-run with corrected types\n}","preventionTips":["Keep each IR local assigned a single consistent type across branches","Run type fixing/SSA passes before any TypeClass.merge use","When handling obfuscated DEX, normalize register types first"],"tags":["type-inference","ir","typeconflict"],"backgroundTag":"type-mismatch","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}