{"record":{"id":"8e37ff4dc9608cd6","repo":"skylot/jadx","slug":"failed-to-generate-invoke-custom-instruction","errorCode":null,"errorMessage":"Failed to generate 'invoke-custom' instruction: ","messagePattern":"Failed to generate 'invoke-custom' instruction: ","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/codegen/InsnGen.java","lineNumber":1028,"sourceCode":"\t\t\t\t}\n\t\t\t\tcode.add(')');\n\t\t\t}\n\t\t\tcode.add(\" -> {\");\n\t\t\tif (fallback) {\n\t\t\t\tcode.add(\" // \").add(implMthInfo.toString());\n\t\t\t}\n\t\t\tcode.incIndent();\n\t\t\tcode.startLine();\n\t\t\tif (!implMthInfo.getReturnType().isVoid()) {\n\t\t\t\tcode.add(\"return \");\n\t\t\t}\n\t\t\tmakeInsn(callInsn, code, Flags.INLINE);\n\t\t\tcode.add(\";\");\n\n\t\t\tcode.decIndent();\n\t\t\tcode.startLine('}');\n\t\t} catch (Exception e) {\n\t\t\tthrow new JadxRuntimeException(\"Failed to generate 'invoke-custom' instruction: \" + e.getMessage(), e);\n\t\t}\n\t}\n\n\tprivate void makeInlinedLambdaMethod(ICodeWriter code, InvokeCustomNode customNode, MethodNode callMth) throws CodegenException {\n\t\tMethodGen callMthGen = new MethodGen(mgen.getClassGen(), callMth);\n\t\tNameGen nameGen = callMthGen.getNameGen();\n\t\tnameGen.inheritUsedNames(this.mgen.getNameGen());\n\n\t\tList<ArgType> implArgs = customNode.getImplMthInfo().getArgumentsTypes();\n\t\tList<RegisterArg> callArgs = callMth.getArgRegs();\n\t\tif (implArgs.isEmpty()) {\n\t\t\tcode.add(\"()\");\n\t\t} else {\n\t\t\tint callArgsCount = callArgs.size();\n\t\t\tint startArg = callArgsCount - implArgs.size();\n\t\t\tif (callArgsCount - startArg > 1) {\n\t\t\t\tcode.add('(');\n\t\t\t}","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/codegen/InsnGen.java#L1010-L1046","documentation":"Thrown by InsnGen when generating an invoke-custom instruction (Java 8+ lambda/method reference) and any exception occurs during the process — building the call arguments, resolving the bootstrap method, or rendering the lambda body. The catch block wraps the original exception with this message. Invoke-custom is one of the most complex codegen paths due to the variety of bootstrap methods and lambda shapes.","triggerScenarios":"Processing an invoke-custom instruction where the call argument resolution or lambda body generation fails. Common with non-standard bootstrap methods, malformed LambdaMetafactory metafactory calls, or unusual method handle types. The inner cause exception has the specifics.","commonSituations":"Modern Java 8+ apps with complex lambda chains. Kotlin/Scala/Groovy compiled code using custom bootstrap methods. Obfuscated apps where invoke-custom metadata has been tampered with.","solutions":["Examine the cause exception for the specific failure point.","Report the class and invoke-custom instruction to jadx with the full stack trace.","Use fallback decompilation mode which may skip lambda reconstruction.","Update jadx — invoke-custom handling is actively improved."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    codeGen.makeCode(cls);\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().startsWith(\"Failed to generate 'invoke-custom'\")) {\n        Throwable cause = e.getCause();\n        logger.error(\"invoke-custom codegen failed for {}: {}\",\n            cls.getClassInfo().getFullName(), cause.getMessage(), e);\n        // Retry with fallback mode that skips lambda reconstruction\n        args.setDecompilationMode(DecompilationMode.FALLBACK);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Examine the cause exception for the specific invoke-custom failure.","Use fallback mode for apps with complex or non-standard lambda/bootstrap patterns.","Update jadx — invoke-custom handling is actively improved in each release."],"tags":["codegen","invoke-custom","lambda","dex","decompiler-bug"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}