{"record":{"id":"70a72181bbd94505","repo":"skylot/jadx","slug":"failed-to-load-method-reference-for-insn","errorCode":null,"errorMessage":"Failed to load method reference for insn: {}","messagePattern":"Failed to load method reference for insn: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java","lineNumber":601,"sourceCode":"\t\tinode.addArg(InsnArg.reg(insn, 2, argType));\n\t\treturn inode;\n\t}\n\n\tprivate InsnNode cast(InsnData insn, ArgType from, ArgType to) {\n\t\tInsnNode inode = new IndexInsnNode(InsnType.CAST, to, 1);\n\t\tinode.setResult(InsnArg.reg(insn, 0, to));\n\t\tinode.addArg(InsnArg.reg(insn, 1, from));\n\t\treturn inode;\n\t}\n\n\tprivate InsnNode invokeCustom(InsnData insn, boolean isRange) {\n\t\treturn InvokeCustomBuilder.build(method, insn, isRange);\n\t}\n\n\tprivate InsnNode invokePolymorphic(InsnData insn, boolean isRange) {\n\t\tIMethodRef mthRef = InsnDataUtils.getMethodRef(insn);\n\t\tif (mthRef == null) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to load method reference for insn: \" + insn);\n\t\t}\n\t\tMethodInfo callMth = MethodInfo.fromRef(root, mthRef);\n\t\tIMethodProto proto = insn.getIndexAsProto(insn.getTarget());\n\n\t\t// expand call args\n\t\tList<ArgType> args = Utils.collectionMap(proto.getArgTypes(), ArgType::parse);\n\t\tArgType returnType = ArgType.parse(proto.getReturnType());\n\t\tMethodInfo effectiveCallMth = MethodInfo.fromDetails(root, callMth.getDeclClass(),\n\t\t\t\tcallMth.getName(), args, returnType);\n\t\treturn new InvokePolymorphicNode(effectiveCallMth, insn, proto, callMth, isRange);\n\t}\n\n\tprivate InsnNode invokeSpecial(InsnData insn) {\n\t\tIMethodRef mthRef = InsnDataUtils.getMethodRef(insn);\n\t\tif (mthRef == null) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to load method reference for insn: \" + insn);\n\t\t}\n\t\tMethodInfo mthInfo = MethodInfo.fromRef(root, mthRef);","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java#L583-L619","documentation":"In invokePolymorphic(), InsnDataUtils.getMethodRef(insn) returned null. That helper returns null when insn.getIndexType() is not METHOD_REF or no payload/index is resolvable. An invoke-polymorphic instruction (MethodHandle.invoke/invokeExact) must reference a method, so a null ref is fatal.","triggerScenarios":"An invoke-polymorphic instruction whose index type is not METHOD_REF, or whose ICustomPayload / index cannot be cast to IMethodRef — indicating a structurally invalid DEX instruction.","commonSituations":"Corrupt DEX, a packer that rewrites invoke-polymorphic sites incorrectly, or a malformed constant pool / method handle table.","solutions":["Upgrade JADX (method-ref resolution for polymorphic invokes has seen fixes across releases).","Validate the DEX with baksmali to confirm the invoke-polymorphic index resolves to a real method.","Skip the class and continue decompiling the rest of the APK.","Report the offending instruction offset and class to the JADX tracker."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    jadx.load();\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().contains(\"Failed to load method reference\")) {\n        log.warn(\"Invoke-polymorphic with unresolved method ref; likely corrupt DEX\", e);\n    } else throw e;\n}","preventionTips":["Validate DEX method_ids and proto_ids with dexdump before decompiling.","Wrap per-class decompilation in try/catch.","Keep JADX updated."],"tags":["invoke-polymorphic","method-ref","malformed-input"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}