{"record":{"id":"99cb1db90e714a06","repo":"JetBrains/intellij-community","slug":"recursive-form-nesting-is-not-allowed","errorCode":null,"errorMessage":"Recursive form nesting is not allowed","messagePattern":"Recursive form nesting is not allowed","errorType":"validation","errorClass":"CodeGenerationException","httpStatus":null,"severity":"error","filePath":"java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/AsmCodeGenerator.java","lineNumber":416,"sourceCode":"        }\n        try {\n          nestedFormContainer = myFormLoader.loadForm(nestedForm.getFormFileName());\n        }\n        catch (Exception e) {\n          throw new CodeGenerationException(lwComponent.getId(), e.getMessage());\n        }\n        // if nested form is empty, ignore\n        if (nestedFormContainer.getComponentCount() == 0) {\n          return;\n        }\n        if (nestedFormContainer.getComponent(0).getBinding() == null) {\n          throw new CodeGenerationException(lwComponent.getId(), \"No binding on root component of nested form \" + nestedForm.getFormFileName());\n        }\n        try {\n          Utils.validateNestedFormLoop(nestedForm.getFormFileName(), myFormLoader);\n        }\n        catch (RecursiveFormNestingException e) {\n          throw new CodeGenerationException(lwComponent.getId(), \"Recursive form nesting is not allowed\");\n        }\n        className = myFormLoader.getClassToBindName(nestedFormContainer);\n      }\n      else {\n        className = getComponentCodeGenerator(lwComponent.getParent()).mapComponentClass(lwComponent.getComponentClassName());\n      }\n      Type componentType = typeFromClassName(className);\n      int componentLocal = generator.newLocal(componentType);\n\n      myIdToLocalMap.put(lwComponent.getId(), Integer.valueOf(componentLocal));\n\n      InstrumentationClassFinder.PseudoClass componentClass = getComponentClass(className, myFinder);\n      validateFieldBinding(lwComponent, componentClass);\n\n      if (myIgnoreCustomCreation) {\n        try {\n          boolean creatable = true;\n          if ((componentClass.getModifiers() & (Modifier.PRIVATE | Modifier.ABSTRACT)) != 0) {","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/AsmCodeGenerator.java#L398-L434","documentation":"During nested-form compilation, Utils.validateNestedFormLoop throws RecursiveFormNestingException when the nested-form graph contains a cycle (form A embeds B which embeds A, directly or transitively); AsmCodeGenerator converts it to CodeGenerationException('Recursive form nesting is not allowed') because expanding such a graph would recurse infinitely.","triggerScenarios":"Compiling a form whose nested-form include chain loops back on itself: A includes B, B includes A; or longer cycles A->B->C->A.","commonSituations":"Copy-pasting forms and re-pointing nested-form references at each other; refactoring a shared panel into a form and accidentally including the container form inside it; hand-editing form XML include paths.","solutions":["Break the cycle: identify it from the exception/chain (A->B->A) and remove or restructure one include so the graph is a DAG","Extract the mutually-shared part into a third form included by both, instead of including each other","If nesting looks accidental, check the nested-form component's formFileName in the designer and repoint it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"try {\n  Utils.validateNestedFormLoop(formFileName, formLoader);\n} catch (RecursiveFormNestingException e) {\n  // report the cycle and which include to remove, before compilation\n}","typeGuard":null,"tryCatchPattern":"catch (CodeGenerationException e) if 'Recursive form nesting is not allowed': trace the include chain, remove one include to break the cycle","preventionTips":["Model nested forms as a DAG: shared UI goes into leaf forms that include nothing cyclic","After copy-pasting forms, audit nested-form references for accidental back-references","Run validateNestedFormLoop in a lint step for large form graphs"],"tags":["gui-designer","forms","nested-forms","cycle-detection","intellij"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}