{"record":{"id":"b1450389fb0407c0","repo":"skylot/jadx","slug":"wrong-literal-type-for-value","errorCode":null,"errorMessage":"Wrong literal type: {} for value: {}","messagePattern":"Wrong literal type: (.+?) for value: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/instructions/args/LiteralArg.java","lineNumber":44,"sourceCode":"\t\tif (value < 0) {\n\t\t\treturn ArgType.NARROW_NEG_NUMBERS;\n\t\t}\n\t\treturn ArgType.NARROW_NUMBERS_NO_BOOL;\n\t}\n\n\tpublic static LiteralArg litFalse() {\n\t\treturn new LiteralArg(0, ArgType.BOOLEAN);\n\t}\n\n\tpublic static LiteralArg litTrue() {\n\t\treturn new LiteralArg(1, ArgType.BOOLEAN);\n\t}\n\n\tprivate final long literal;\n\n\tprivate LiteralArg(long value, ArgType type) {\n\t\tif (value != 0 && type.isObject()) {\n\t\t\tthrow new JadxRuntimeException(\"Wrong literal type: \" + type + \" for value: \" + value);\n\t\t}\n\t\tthis.literal = value;\n\t\tthis.type = type;\n\t}\n\n\tpublic long getLiteral() {\n\t\treturn literal;\n\t}\n\n\t@Override\n\tpublic void setType(ArgType type) {\n\t\tsuper.setType(type);\n\t}\n\n\t@Override\n\tpublic boolean isLiteral() {\n\t\treturn true;\n\t}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/instructions/args/LiteralArg.java#L26-L62","documentation":"LiteralArg's private constructor rejects a non-zero value paired with an object type. A non-zero object literal is semantically impossible in the JVM (object references are not literals), so the constructor throws immediately. This is an internal invariant guard, not normally reachable from external input.","triggerScenarios":"Internal code constructs LiteralArg.make(nonZero, someObjectType) — a type-inference or instruction-building bug that assigns an object type to a non-zero literal.","commonSituations":"A regression in JADX's type inference or literal handling, or a plugin/extension that misuses the LiteralArg constructor. Rarely triggered by input alone.","solutions":["Upgrade JADX.","If extending JADX, audit your use of LiteralArg.make to ensure object types are only used with value 0.","Use LiteralArg.makeWithFixedType to let JADX correct the type automatically.","Report the method/insn and full trace to the JADX tracker."],"exampleFix":"// before\nnew LiteralArg(5, ArgType.OBJECT) // throws\n\n// after\nLiteralArg.makeWithFixedType(5, ArgType.INT) // safe: type auto-fixed","handlingStrategy":"type-guard","validationCode":"// If you construct LiteralArg values in a plugin/extension, guard the type.\nstatic LiteralArg safeLit(long value, ArgType type) {\n    if (value != 0 && type.isObject()) {\n        type = ArgType.NARROW_NUMBERS; // demote to numeric\n    }\n    return LiteralArg.make(value, type);\n}","typeGuard":"// Narrow before constructing: never pair a non-zero value with an object type.\nstatic boolean isSafeLiteral(long value, ArgType type) {\n    return value == 0 || !type.isObject();\n}","tryCatchPattern":"try {\n    LiteralArg arg = LiteralArg.make(value, type);\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().contains(\"Wrong literal type\")) {\n        arg = LiteralArg.makeWithFixedType(value, ArgType.INT);\n    } else throw e;\n}","preventionTips":["Prefer LiteralArg.makeWithFixedType over make when the type is uncertain.","Never construct a non-zero object-typed literal — it is semantically invalid in the JVM.","Audit custom plugins for LiteralArg misuse."],"tags":["literalarg","type-inference","internal-bug"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}