skylot/jadx · error · JadxRuntimeException
Unknown output format
Error message
Unknown output format
What it means
Thrown by CodeGen.makeCode() as the default branch of the switch on args.getOutputFormat(). The OutputFormatEnum currently defines only JAVA and JSON. Reaching the default means a new output format constant was added to the enum without a corresponding case in this switch — a development-time guard against incomplete format support.
Source
Thrown at jadx-core/src/main/java/jadx/core/codegen/CodeGen.java:28
import jadx.core.dex.nodes.ClassNode;
import jadx.core.utils.exceptions.JadxRuntimeException;
public class CodeGen {
public static ICodeInfo generate(ClassNode cls) {
if (cls.contains(AFlag.DONT_GENERATE)) {
return ICodeInfo.EMPTY;
}
JadxArgs args = cls.root().getArgs();
switch (args.getOutputFormat()) {
case JAVA:
return generateJavaCode(cls, args);
case JSON:
return generateJson(cls);
default:
throw new JadxRuntimeException("Unknown output format");
}
}
private static ICodeInfo generateJavaCode(ClassNode cls, JadxArgs args) {
ClassGen clsGen = new ClassGen(cls, args);
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) {View on GitHub (pinned to e738a26571)
Solutions
- If adding a new OutputFormatEnum value, add a matching case in CodeGen.makeCode() that calls the appropriate generator.
- Ensure the switch is exhaustive — consider using an exhaustive enum pattern or a map of OutputFormatEnum to generator functions.
Example fix
// before
// switch (args.getOutputFormat()) {
// case JAVA: ...
// case JSON: ...
// default: throw ...
// }
// after
// case KOTLIN: return generateKotlinCode(cls, args); Defensive patterns
Strategy: validation
Validate before calling
// Ensure only supported output formats are used
JadxArgs args = new JadxArgs();
OutputFormatEnum fmt = args.getOutputFormat();
if (fmt != OutputFormatEnum.JAVA && fmt != OutputFormatEnum.JSON) {
throw new IllegalArgumentException("Unsupported output format: " + fmt);
}
// Only JAVA and JSON are currently supported by CodeGen Prevention
- If adding a new OutputFormatEnum, update ALL switch sites including CodeGen.makeCode().
- Prefer an exhaustive enum handler (map or sealed pattern) over raw switches.
- Add unit tests for each output format to catch missing branches.
When it happens
Trigger: A new OutputFormatEnum constant (e.g., KOTLIN, SMALI) is added to JadxArgs but CodeGen.makeCode() is not updated with a matching case. Cannot occur with the currently shipped enum.
Common situations: Contributing a new output format to jadx and forgetting to add the generation branch. Forking jadx and adding an enum value without updating all switch sites.
Related errors
- Unknown condition mode:
- Unknown arg type
- Unknown instruction:
- Unknown loop type:
- Unexpected field type class:
AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14).
Data as JSON: /api/errors/b230b69f278b7620.
Report an issue: GitHub.