{"record":{"id":"74c5385227477ffb","repo":"skylot/jadx","slug":"method-generation-error","errorCode":null,"errorMessage":"Method generation error","messagePattern":"Method generation error","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/codegen/ClassGen.java","lineNumber":348,"sourceCode":"\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate void addMethod(ICodeWriter code, MethodNode mth) {\n\t\tif (skipMethod(mth)) {\n\t\t\treturn;\n\t\t}\n\t\tif (code.getLength() != clsDeclOffset) {\n\t\t\tcode.newLine();\n\t\t}\n\t\tint savedIndent = code.getIndent();\n\t\ttry {\n\t\t\taddMethodCode(code, mth);\n\t\t} catch (Exception e) {\n\t\t\tif (mth.getParentClass().getTopParentClass().contains(AFlag.RESTART_CODEGEN)) {\n\t\t\t\tthrow new JadxRuntimeException(\"Method generation error\", e);\n\t\t\t}\n\t\t\tmth.addError(\"Method generation error\", e);\n\t\t\tCodeGenUtils.addErrors(code, mth);\n\t\t\tcode.setIndent(savedIndent);\n\t\t}\n\t}\n\n\t/**\n\t * Additional checks for inlined methods\n\t */\n\tprivate boolean skipMethod(MethodNode mth) {\n\t\tif (cls.root().getArgs().getDecompilationMode().isSpecial()) {\n\t\t\t// show all methods for special decompilation modes\n\t\t\treturn false;\n\t\t}\n\t\tMethodInlineAttr inlineAttr = mth.get(AType.METHOD_INLINE);\n\t\tif (inlineAttr == null || inlineAttr.notNeeded()) {\n\t\t\treturn false;","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/codegen/ClassGen.java#L330-L366","documentation":"Thrown by ClassGen.addMethod() when addMethodCode() throws an exception AND the class already has the RESTART_CODEGEN flag set. This means the codegen has already been restarted once (typically due to anonymous class inlining) and the method still fails on the second pass. Rather than silently swallowing the error, jadx escalates it to a fatal runtime exception.","triggerScenarios":"A method that fails to decompile during code generation, where the containing class was already marked for codegen restart (e.g., due to anonymous inner class conversion). The second attempt at addMethodCode() also throws.","commonSituations":"Complex bytecode patterns in obfuscated apps that trip up codegen twice. Anonymous classes with intricate constructor logic that causes restart and still fails. Edge cases in invoke-custom or lambda processing.","solutions":["Report the method/class to jadx with the full stack trace — this is an internal decompiler limitation.","Use --decompilation-mode FALLBACK or set JadxArgs.decompilationMode to a simpler mode that avoids aggressive transformations.","Exclude the problematic class from the decompilation set if only specific classes are needed."],"exampleFix":"// before\n//   JadxArgs args = new JadxArgs();\n//   args.setDecompilationMode(DecompilationMode.AUTO);\n// after\n//   args.setDecompilationMode(DecompilationMode.FALLBACK);","handlingStrategy":"fallback","validationCode":"// Use a simpler decompilation mode to avoid restart-triggering transforms\nJadxArgs args = new JadxArgs();\nargs.setDecompilationMode(DecompilationMode.FALLBACK);\n// FALLBACK avoids anonymous class inlining and other aggressive transforms\n// that can trigger RESTART_CODEGEN cycles","typeGuard":null,"tryCatchPattern":"try {\n    jadxDecompiler.decompile();\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().equals(\"Method generation error\")) {\n        logger.error(\"Method failed even after codegen restart. Retrying with fallback mode.\", e);\n        // Retry the specific class with fallback mode\n        args.setDecompilationMode(DecompilationMode.FALLBACK);\n        // re-decompile\n    }\n    throw e;\n}","preventionTips":["For obfuscated or complex apps, start with DecompilationMode.SIMPLE or FALLBACK.","Report methods that fail after restart to the jadx project.","Process classes individually to isolate failures rather than failing the entire batch."],"tags":["codegen","restart","method","decompiler-bug"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}