{"record":{"id":"508a320f58379f66","repo":"skylot/jadx","slug":"unknown-loop-type","errorCode":null,"errorMessage":"Unknown loop type: ","messagePattern":"Unknown loop type: ","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/codegen/RegionGen.java","lineNumber":211,"sourceCode":"\t\t\t\tcode.add(\") {\");\n\t\t\t\tCodeGenUtils.addCodeComments(code, mth, condInsn);\n\t\t\t\tmakeRegionIndent(code, region.getBody());\n\t\t\t\tcode.startLine('}');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type instanceof ForEachLoop) {\n\t\t\t\tForEachLoop forEachLoop = (ForEachLoop) type;\n\t\t\t\tcode.add(\"for (\");\n\t\t\t\tdeclareVar(code, forEachLoop.getVarArg());\n\t\t\t\tcode.add(\" : \");\n\t\t\t\taddArg(code, forEachLoop.getIterableArg(), false);\n\t\t\t\tcode.add(\") {\");\n\t\t\t\tCodeGenUtils.addCodeComments(code, mth, condInsn);\n\t\t\t\tmakeRegionIndent(code, region.getBody());\n\t\t\t\tcode.startLine('}');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new JadxRuntimeException(\"Unknown loop type: \" + type.getClass());\n\t\t}\n\t\tif (region.isConditionAtEnd()) {\n\t\t\tcode.add(\"do {\");\n\t\t\tCodeGenUtils.addCodeComments(code, mth, condInsn);\n\t\t\tmakeRegionIndent(code, region.getBody());\n\t\t\tcode.startLineWithNum(region.getSourceLine());\n\t\t\tcode.add(\"} while (\");\n\t\t\tconditionGen.add(code, condition);\n\t\t\tcode.add(\");\");\n\t\t} else {\n\t\t\tcode.add(\"while (\");\n\t\t\tconditionGen.add(code, condition);\n\t\t\tcode.add(\") {\");\n\t\t\tCodeGenUtils.addCodeComments(code, mth, condInsn);\n\t\t\tmakeRegionIndent(code, region.getBody());\n\t\t\tcode.startLine('}');\n\t\t}\n\t}","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/codegen/RegionGen.java#L193-L229","documentation":"Thrown by RegionGen when generating a loop region whose LoopType is neither ForLoop nor ForEachLoop. These are the only two concrete loop types in jadx's region model. Hitting this exception means a new LoopType subclass exists or the region tree was corrupted to contain an unexpected loop type.","triggerScenarios":"A LoopRegion whose getLoop() returns a LoopType implementation other than ForLoop or ForEachLoop. Adding a new loop type (e.g., a WhileLoop abstraction) without updating RegionGen. Internal corruption of the region tree.","commonSituations":"Contributing new loop abstractions to jadx without updating all consumers. Extremely rare in user-facing decompilation — this is a developer-facing exhaustive-type-check guard.","solutions":["If you added a new LoopType subclass, add an instanceof check and handling in RegionGen.","Report as an internal jadx bug with the class and stack trace."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    regionGen.makeRegion(code, region);\n} catch (JadxRuntimeException e) {\n    if (e.getMessage().startsWith(\"Unknown loop type\")) {\n        code.startLine(\"/* unknown loop type: \" + loopType.getClass() + \" */\");\n        logger.warn(\"Unhandled loop type in codegen\", e);\n        // Continue with other regions\n    } else {\n        throw e;\n    }\n}","preventionTips":["If you add a new LoopType subclass, add an instanceof branch in RegionGen.","Report as an internal jadx bug — this guard should be unreachable in shipped code."],"tags":["codegen","region","loop","exhaustive-switch","internal-bug"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}