skylot/jadx · error · JadxRuntimeException
Code generation error
Error message
Code generation error
What it means
Thrown by CodeGen.wrapCodeGen() on the first code generation failure when the RESTART_CODEGEN flag is not set on the class. This is the standard fatal path for any uncaught exception during makeClass() or JSON generation that has no recovery mechanism. The original exception is wrapped as the cause.
Source
Thrown at jadx-core/src/main/java/jadx/core/codegen/CodeGen.java:55
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
- Examine the wrapped cause exception — it contains the actual failure point and is the primary diagnostic.
- Report the class and stack trace to the jadx issue tracker.
- Try DecompilationMode.FALLBACK or exclude the class.
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate class is processable before codegen
if (cls.contains(AFlag.DONT_GENERATE)) {
return; // skip
}
// Use try-with-error-collection per class
try {
codeGen.makeCode(cls);
} catch (JadxRuntimeException e) {
cls.addError("Code generation error", e);
// continue with other classes instead of aborting the batch
} Try / catch
try {
ICodeInfo code = CodeGen.makeCode(cls);
} catch (JadxRuntimeException e) {
if (e.getMessage().equals("Code generation error")) {
Throwable cause = e.getCause();
logger.error("Failed to generate code for class {}: {}",
cls.getClassInfo().getFullName(), cause.getMessage(), e);
cls.addError("Code generation error", cause);
// Continue with other classes
} else {
throw e;
}
} Prevention
- Always examine the wrapped cause exception — it has the actual failure.
- Process classes individually and catch exceptions per-class to avoid batch failures.
- Use fallback decompilation mode for classes that consistently fail.
When it happens
Trigger: Any exception thrown during ClassGen.makeClass() or JsonCodeGen.process() where the class does not have RESTART_CODEGEN set. This is the catch-all for code generation failures that are not eligible for the restart recovery path.
Common situations: Unhandled instruction types, unexpected null references, or logic errors during class code generation. Corrupted or unusual bytecode that triggers an uncaught exception.
Related errors
- Error generate insn:
- Method generation error
- Code generation error after restart
- Constructor 'self' invoke must be removed!
- Failed to generate 'invoke-custom' instruction:
AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14).
Data as JSON: /api/errors/790c9d82739829eb.
Report an issue: GitHub.