{"record":{"id":"9abd50e21a38882e","repo":"skylot/jadx","slug":"arg-not-found","errorCode":null,"errorMessage":"Arg not found: ","messagePattern":"Arg not found: ","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/attributes/nodes/SkipMethodArgsAttr.java","lineNumber":20,"sourceCode":"\nimport java.util.BitSet;\n\nimport org.jetbrains.annotations.Nullable;\n\nimport jadx.api.plugins.input.data.attributes.PinnedAttribute;\nimport jadx.core.dex.attributes.AFlag;\nimport jadx.core.dex.attributes.AType;\nimport jadx.core.dex.instructions.args.RegisterArg;\nimport jadx.core.dex.nodes.MethodNode;\nimport jadx.core.utils.Utils;\nimport jadx.core.utils.exceptions.JadxRuntimeException;\n\npublic class SkipMethodArgsAttr extends PinnedAttribute {\n\n\tpublic static void skipArg(MethodNode mth, RegisterArg arg) {\n\t\tint argNum = Utils.indexInListByRef(mth.getArgRegs(), arg);\n\t\tif (argNum == -1) {\n\t\t\tthrow new JadxRuntimeException(\"Arg not found: \" + arg);\n\t\t}\n\t\tskipArg(mth, argNum);\n\t}\n\n\tpublic static void skipArg(MethodNode mth, int argNum) {\n\t\tSkipMethodArgsAttr attr = mth.get(AType.SKIP_MTH_ARGS);\n\t\tif (attr == null) {\n\t\t\tattr = new SkipMethodArgsAttr(mth);\n\t\t\tmth.addAttr(attr);\n\t\t}\n\t\tattr.skip(argNum);\n\t}\n\n\tpublic static boolean isSkip(@Nullable MethodNode mth, int argNum) {\n\t\tif (mth == null) {\n\t\t\treturn false;\n\t\t}\n\t\tif (argNum == 0 && mth.contains(AFlag.SKIP_FIRST_ARG)) {","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/SkipMethodArgsAttr.java#L2-L38","documentation":"Thrown by SkipMethodArgsAttr.skipArg(MethodNode, RegisterArg) when the given RegisterArg is not found by reference in the method's argument register list (Utils.indexInListByRef returns -1). It indicates the caller asked to skip a register that is not actually a declared argument of the method.","triggerScenarios":"Passing a RegisterArg that is a copy, a this-pointer, or an intra-body temporary rather than a true argument register; calling skipArg with an arg belonging to a different MethodNode; calling after argument-register list has been rebuilt so the reference no longer matches.","commonSituations":"Plugins or post-processing passes that mark arguments to skip without checking membership; transformations that replace arg registers and leave stale references; bugs in caller code that confuses arg regs with locals.","solutions":["Before calling, confirm the arg is in mth.getArgRegs() by reference (Utils.indexInListByRef != -1).","Use the integer-index overload skipArg(mth, argNum) once you have resolved the index yourself, with a guard for -1.","Make sure the RegisterArg comes from the same MethodNode instance and is the original arg, not a renamed copy.","If skipping should be best-effort, log and ignore a -1 result instead of throwing."],"exampleFix":"// before\npublic static void skipArg(MethodNode mth, RegisterArg arg) {\n    int argNum = Utils.indexInListByRef(mth.getArgRegs(), arg);\n    if (argNum == -1) {\n        throw new JadxRuntimeException(\"Arg not found: \" + arg);\n    }\n    skipArg(mth, argNum);\n}\n\n// after (guard at the call site)\nint idx = Utils.indexInListByRef(mth.getArgRegs(), arg);\nif (idx != -1) {\n    SkipMethodArgsAttr.skipArg(mth, idx);\n}","handlingStrategy":"validation","validationCode":"int idx = Utils.indexInListByRef(mth.getArgRegs(), arg);\nif (idx == -1) {\n    // arg is not a declared argument; do not skip\n    return;\n}\nSkipMethodArgsAttr.skipArg(mth, idx);","typeGuard":"static boolean isMethodArg(MethodNode mth, RegisterArg arg) {\n    return Utils.indexInListByRef(mth.getArgRegs(), arg) != -1;\n}","tryCatchPattern":"try {\n    SkipMethodArgsAttr.skipArg(mth, arg);\n} catch (JadxRuntimeException e) {\n    LOG.warn(\"Cannot skip arg {} in {}: not an argument register\", arg, mth);\n}","preventionTips":["Resolve the argument index yourself and guard for -1 before calling.","Ensure the RegisterArg is from the same MethodNode and is the original arg register, not a copy.","Prefer the integer-index overload skipArg(mth, int) once validated."],"tags":["api-misuse","method-args","validation"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}