{"record":{"id":"b230b69f278b7620","repo":"skylot/jadx","slug":"unknown-output-format","errorCode":null,"errorMessage":"Unknown output format","messagePattern":"Unknown output format","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/codegen/CodeGen.java","lineNumber":28,"sourceCode":"import jadx.core.dex.nodes.ClassNode;\nimport jadx.core.utils.exceptions.JadxRuntimeException;\n\npublic class CodeGen {\n\n\tpublic static ICodeInfo generate(ClassNode cls) {\n\t\tif (cls.contains(AFlag.DONT_GENERATE)) {\n\t\t\treturn ICodeInfo.EMPTY;\n\t\t}\n\t\tJadxArgs args = cls.root().getArgs();\n\t\tswitch (args.getOutputFormat()) {\n\t\t\tcase JAVA:\n\t\t\t\treturn generateJavaCode(cls, args);\n\n\t\t\tcase JSON:\n\t\t\t\treturn generateJson(cls);\n\n\t\t\tdefault:\n\t\t\t\tthrow new JadxRuntimeException(\"Unknown output format\");\n\t\t}\n\t}\n\n\tprivate static ICodeInfo generateJavaCode(ClassNode cls, JadxArgs args) {\n\t\tClassGen clsGen = new ClassGen(cls, args);\n\t\treturn wrapCodeGen(cls, clsGen::makeClass);\n\t}\n\n\tprivate static ICodeInfo generateJson(ClassNode cls) {\n\t\tJsonCodeGen codeGen = new JsonCodeGen(cls);\n\t\tString clsJson = wrapCodeGen(cls, codeGen::process);\n\t\treturn new SimpleCodeInfo(clsJson);\n\t}\n\n\tprivate static <R> R wrapCodeGen(ClassNode cls, Callable<R> codeGenFunc) {\n\t\ttry {\n\t\t\treturn codeGenFunc.call();\n\t\t} catch (Exception e) {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/codegen/CodeGen.java#L10-L46","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n//   switch (args.getOutputFormat()) {\n//       case JAVA: ...\n//       case JSON: ...\n//       default: throw ...\n//   }\n// after\n//       case KOTLIN: return generateKotlinCode(cls, args);","handlingStrategy":"validation","validationCode":"// Ensure only supported output formats are used\nJadxArgs args = new JadxArgs();\nOutputFormatEnum fmt = args.getOutputFormat();\nif (fmt != OutputFormatEnum.JAVA && fmt != OutputFormatEnum.JSON) {\n    throw new IllegalArgumentException(\"Unsupported output format: \" + fmt);\n}\n// Only JAVA and JSON are currently supported by CodeGen","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["codegen","output-format","exhaustive-switch","internal-bug"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}