JetBrains/intellij-community · error · CodeGenerationException
Recursive form nesting is not allowed
Error message
Recursive form nesting is not allowed
What it means
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.
Source
Thrown at java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/AsmCodeGenerator.java:416
}
try {
nestedFormContainer = myFormLoader.loadForm(nestedForm.getFormFileName());
}
catch (Exception e) {
throw new CodeGenerationException(lwComponent.getId(), e.getMessage());
}
// if nested form is empty, ignore
if (nestedFormContainer.getComponentCount() == 0) {
return;
}
if (nestedFormContainer.getComponent(0).getBinding() == null) {
throw new CodeGenerationException(lwComponent.getId(), "No binding on root component of nested form " + nestedForm.getFormFileName());
}
try {
Utils.validateNestedFormLoop(nestedForm.getFormFileName(), myFormLoader);
}
catch (RecursiveFormNestingException e) {
throw new CodeGenerationException(lwComponent.getId(), "Recursive form nesting is not allowed");
}
className = myFormLoader.getClassToBindName(nestedFormContainer);
}
else {
className = getComponentCodeGenerator(lwComponent.getParent()).mapComponentClass(lwComponent.getComponentClassName());
}
Type componentType = typeFromClassName(className);
int componentLocal = generator.newLocal(componentType);
myIdToLocalMap.put(lwComponent.getId(), Integer.valueOf(componentLocal));
InstrumentationClassFinder.PseudoClass componentClass = getComponentClass(className, myFinder);
validateFieldBinding(lwComponent, componentClass);
if (myIgnoreCustomCreation) {
try {
boolean creatable = true;
if ((componentClass.getModifiers() & (Modifier.PRIVATE | Modifier.ABSTRACT)) != 0) {View on GitHub (pinned to be881553f2)
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
Defensive patterns
Strategy: validation
Validate before calling
try {
Utils.validateNestedFormLoop(formFileName, formLoader);
} catch (RecursiveFormNestingException e) {
// report the cycle and which include to remove, before compilation
} Try / catch
catch (CodeGenerationException e) if 'Recursive form nesting is not allowed': trace the include chain, remove one include to break the cycle
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Attempt to compile nested form with no nested form loader sp
- No binding on root component of nested form
- Class not found:
- Unsupported class version error:
- Error loading nested form:
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/99cb1db90e714a06.
Report an issue: GitHub.