{"record":{"id":"043b388d07a4d9b1","repo":"skylot/jadx","slug":"several-immutable-types-in-one-variable-vars","errorCode":null,"errorMessage":"Several immutable types in one variable: {}, vars: {}","messagePattern":"Several immutable types in one variable: (.+?), vars: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/visitors/InitCodeVariables.java","lineNumber":107,"sourceCode":"\t\t\t});\n\t\t} else {\n\t\t\tssaVar.setCodeVar(codeVar);\n\t\t}\n\t}\n\n\tprivate static void setCodeVarType(CodeVar codeVar, Set<SSAVar> vars) {\n\t\tif (vars.size() > 1) {\n\t\t\tList<ArgType> imTypes = vars.stream()\n\t\t\t\t\t.map(SSAVar::getImmutableType)\n\t\t\t\t\t.filter(Objects::nonNull)\n\t\t\t\t\t.filter(ArgType::isTypeKnown)\n\t\t\t\t\t.distinct()\n\t\t\t\t\t.collect(Collectors.toList());\n\t\t\tint imCount = imTypes.size();\n\t\t\tif (imCount == 1) {\n\t\t\t\tcodeVar.setType(imTypes.get(0));\n\t\t\t} else if (imCount > 1) {\n\t\t\t\tthrow new JadxRuntimeException(\"Several immutable types in one variable: \" + imTypes + \", vars: \" + vars);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void collectConnectedVars(List<PhiInsn> phiInsnList, Set<SSAVar> vars) {\n\t\tif (phiInsnList.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\t\tfor (PhiInsn phiInsn : phiInsnList) {\n\t\t\tSSAVar resultVar = phiInsn.getResult().getSVar();\n\t\t\tif (vars.add(resultVar)) {\n\t\t\t\tcollectConnectedVars(resultVar.getPhiList(), vars);\n\t\t\t}\n\t\t\tphiInsn.getArguments().forEach(arg -> {\n\t\t\t\tSSAVar sVar = ((RegisterArg) arg).getSVar();\n\t\t\t\tif (vars.add(sVar)) {\n\t\t\t\t\tcollectConnectedVars(sVar.getPhiList(), vars);\n\t\t\t\t}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/visitors/InitCodeVariables.java#L89-L125","documentation":"Thrown by InitCodeVariables.setCodeVarType() when a single code variable (a logical variable formed by connected SSA vars through PHI instructions) has more than one distinct, known, immutable type. Immutable types (e.g. primitives, strings) are used to infer variable types; finding two different immutable types in one variable is an inconsistency that indicates a type-inference conflict.","triggerScenarios":"setCodeVarType() collects all SSA vars connected via PHI, maps each to its immutable type, filters to known and distinct types, and finds imCount > 1. This means two connected SSA variables carry different immutable type information — e.g. one is inferred as int, another as float — through a PHI merge.","commonSituations":"Complex bytecode with unusual type flows, often from bytecode optimisers or obfuscators that merge registers of different types. Can also arise from type-inference edge cases in code with heavy arithmetic or conditional assignments.","solutions":["Upgrade jadx — type-inference and code-variable logic are continuously refined.","Catch JadxRuntimeException per class/method and continue with remaining decompilation.","Report the issue with the type list and SSA vars from the error message.","Try disabling type-inference-related optimizations via jadx args."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    javaClass.decompile();\n} catch (JadxRuntimeException e) {\n    LOG.warn(\"Type-inference conflict in {}: {}\", javaClass.getName(), e.getMessage());\n}","preventionTips":["Upgrade jadx — type-inference and SSA logic are continuously refined.","Isolate per-class with try-catch.","Report the conflicting types and SSA vars from the error message.","Try disabling type-inference optimizations via args."],"tags":["jadx","decompiler","type-inference","ssa","phi","code-variable","immutable-type"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}