skylot/jadx · error · JadxRuntimeException
Code generation error after restart
Error message
Code generation error after restart
What it means
Thrown by CodeGen.wrapCodeGen() when a second attempt at code generation also fails. The method first tries codeGenFunc.call(); on exception, if RESTART_CODEGEN is set, it removes the flag and retries. If the retry also throws, it wraps the second exception in a JadxRuntimeException with this message. This is the terminal failure after the anonymous-class-inlining recovery path has been exhausted.
Source
Thrown at jadx-core/src/main/java/jadx/core/codegen/CodeGen.java:52
return wrapCodeGen(cls, clsGen::makeClass);
}
private static ICodeInfo generateJson(ClassNode cls) {
JsonCodeGen codeGen = new JsonCodeGen(cls);
String clsJson = wrapCodeGen(cls, codeGen::process);
return new SimpleCodeInfo(clsJson);
}
private static <R> R wrapCodeGen(ClassNode cls, Callable<R> codeGenFunc) {
try {
return codeGenFunc.call();
} catch (Exception e) {
if (cls.contains(AFlag.RESTART_CODEGEN)) {
cls.remove(AFlag.RESTART_CODEGEN);
try {
return codeGenFunc.call();
} catch (Exception ex) {
throw new JadxRuntimeException("Code generation error after restart", ex);
}
} else {
throw new JadxRuntimeException("Code generation error", e);
}
}
}
private CodeGen() {
}
}
View on GitHub (pinned to e738a26571)
Solutions
- Report the class to the jadx project with the full stack trace (the inner cause exception is the key diagnostic).
- Switch to DecompilationMode.FALLBACK which bypasses many of the aggressive transforms that trigger restarts.
- Exclude the problematic class from decompilation.
Example fix
// before // JadxArgs args = new JadxArgs(); // args.setDecompilationMode(DecompilationMode.AUTO); // after // args.setDecompilationMode(DecompilationMode.FALLBACK);
Defensive patterns
Strategy: fallback
Validate before calling
// Set fallback mode to avoid the restart-triggering code paths JadxArgs args = new JadxArgs(); args.setDecompilationMode(DecompilationMode.FALLBACK); // This bypasses anonymous class inlining that causes RESTART_CODEGEN
Try / catch
try {
jadxDecompiler.decompile();
} catch (JadxRuntimeException e) {
if (e.getMessage().equals("Code generation error after restart")) {
logger.error("Codegen failed after restart. The cause exception has the root failure.", e);
// Examine e.getCause() for the actual failure on the second attempt
}
throw e;
} Prevention
- Examine the cause exception — it contains the real failure from the restart attempt.
- Use DecompilationMode.FALLBACK for classes that trigger restart failures.
- Report classes with anonymous-class recursion to the jadx project.
When it happens
Trigger: Anonymous class inlining triggers RESTART_CODEGEN, the class codegen restarts, and the restart attempt also encounters an exception. The original exception from the first attempt is lost; only the second (restart) exception is captured.
Common situations: Complex nested anonymous classes where the conversion-to-inner-class recovery still cannot generate valid code. Obfuscated code with unusual constructor or lambda patterns.
Related errors
- Method generation error
- Anonymous inner class unlimited recursion detected. Convert
- Code generation error
- Error generate insn:
- Constructor 'self' invoke must be removed!
AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14).
Data as JSON: /api/errors/05fe60a67ba50ee7.
Report an issue: GitHub.