skylot/jadx · error · JadxRuntimeException

Failed to generate code for class: ${cls.getFullName()}

Error message

Failed to generate code for class: ${cls.getFullName()}

What it means

Thrown by ProcessClass.generateCode when any exception or StackOverflowError occurs during full code generation for a class (including processing its dependencies and codegen dependencies). Jadx wraps the root cause in a JadxRuntimeException so callers get a uniform failure type with the fully-qualified class name. The inner cause is typically a decompiler bug, malformed bytecode, or recursive type reference causing StackOverflowError.

Source

Thrown at jadx-core/src/main/java/jadx/core/ProcessClass.java:133

				process(cls, false);
				return NOT_GENERATED;
			}
			for (ClassNode depCls : cls.getDependencies()) {
				process(depCls, false);
			}
			if (!cls.getCodegenDeps().isEmpty()) {
				process(cls, false);
				for (ClassNode codegenDep : cls.getCodegenDeps()) {
					process(codegenDep, false);
				}
			}
			ICodeInfo code = process(cls, true);
			if (code == null) {
				throw new JadxRuntimeException("Codegen failed");
			}
			return code;
		} catch (StackOverflowError | Exception e) {
			throw new JadxRuntimeException("Failed to generate code for class: " + cls.getFullName(), e);
		}
	}

	/**
	 * Load and process class without its deps
	 */
	public void forceProcess(ClassNode cls) {
		ClassNode topParentClass = cls.getTopParentClass();
		if (topParentClass != cls) {
			forceProcess(topParentClass);
			return;
		}
		try {
			process(cls, false);
		} catch (StackOverflowError | Exception e) {
			throw new JadxRuntimeException("Failed to process class: " + cls.getFullName(), e);
		}
	}

View on GitHub (pinned to e738a26571)

Solutions

  1. Examine the cause (getCause()) in the stack trace to identify the failing pass or visitor — the message alone only names the class.
  2. Try a different DecompilationMode (e.g., FALLBACK or SIMPLIFY) via forceGenerateCodeForMode to get partial output.
  3. Report the class and full stack trace to the jadx issue tracker if it appears to be a decompiler bug.
  4. Increase the JVM thread stack size (-Xss4m or higher) if StackOverflowError is the root cause, especially for deep type hierarchies.

Example fix

// before
ICodeInfo code = processClass.generateCode(cls);

// after: wrap and fall back to a simpler mode
ICodeInfo code;
try {
    code = processClass.generateCode(cls);
} catch (JadxRuntimeException e) {
    LOG.warn("Codegen failed for {}, trying fallback mode", cls.getFullName(), e);
    code = processClass.forceGenerateCodeForMode(cls, DecompilationMode.FALLBACK);
}
Defensive patterns

Strategy: try-catch

Try / catch

ICodeInfo code;
try {
    code = processClass.generateCode(cls);
} catch (JadxRuntimeException e) {
    LOG.warn("Failed to generate code for {}: {}", cls.getFullName(), e.getCause().getMessage());
    code = processClass.forceGenerateCodeForMode(cls, DecompilationMode.FALLBACK);
}

Prevention

When it happens

Trigger: Calling ProcessClass.generateCode(cls) on a ClassNode whose decompilation triggers an exception in any visitor pass or in CodeGen. The try block covers dependency processing (getDependencies, getCodegenDeps), the main process(cls, true) call, and the null-code check. The most common proximate cause is a StackOverflowError from deeply nested or self-referential type structures, or an NPE in a visitor pass.

Common situations: Decompiling obfuscated or malformed APKs/JARs with unusual bytecode patterns. Processing classes with circular dependencies or very deep generic type hierarchies. Running jadx on an input built with an unsupported or experimental bytecode version. This is the single most common error end-users of jadx-cli encounter on difficult inputs.

Related errors


AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14). Data as JSON: /api/errors/b3ea439ee814627d. Report an issue: GitHub.