JetBrains/intellij-community · error · CodeGenerationException

Attempt to compile nested form with no nested form loader sp

Error message

Attempt to compile nested form with no nested form loader specified

What it means

generateSetupCodeForComponent throws CodeGenerationException when a form contains a LwNestedForm component but AsmCodeGenerator was constructed with myFormLoader == null. Nested forms can only be compiled through a FormLoader that can fetch the nested .form file.

Source

Thrown at java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/AsmCodeGenerator.java:397

        generateButtonGroups(myRootContainer, generator);
      }
      catch (CodeGenerationException e) {
        myErrors.add(new FormErrorInfo(e.getComponentId(), e.getMessage()));
      }
      generator.returnValue();
      generator.endMethod();
    }

    private void generateSetupCodeForComponent(final LwComponent lwComponent,
                                               final GeneratorAdapter generator,
                                               final int parentLocal) throws CodeGenerationException {

      String className;
      if (lwComponent instanceof LwNestedForm) {
        LwRootContainer nestedFormContainer;
        LwNestedForm nestedForm = (LwNestedForm) lwComponent;
        if (myFormLoader == null) {
          throw new CodeGenerationException(null, "Attempt to compile nested form with no nested form loader specified");
        }
        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) {

View on GitHub (pinned to be881553f2)

Solutions

  1. Pass a proper nested FormLoader (the one the standard GUI Designer compiler passes) when constructing AsmCodeGenerator for forms containing nested forms
  2. If nested forms are not expected, remove the nested-form component from the .form or fix the wrong component type in the form XML
  3. Compile through the standard build pipeline (JPS/Gradle IntelliJ Plugin) instead of invoking the generator manually
Defensive patterns

Strategy: validation

Validate before calling

if (formContainsNestedForms(formFile) && formLoader == null) {
  throw new IllegalArgumentException("supply a FormLoader: form embeds nested forms");
}

Try / catch

catch (CodeGenerationException e) if 'no nested form loader specified': wire the standard FormLoader (as JPS forms patcher does) and retry the compile

Prevention

When it happens

Trigger: Running AsmCodeGenerator over a form that embeds another form (nested form component) without supplying a nested form loader to the generator/patcher (e.g. custom instrumentation entry points, or compiling single forms in isolation).

Common situations: Third-party build scripts invoking the forms compiler directly without the standard loader; IDE compile of a form snapshot where the loader was deliberately omitted; hot-swap/instrumentation of an isolated class file that references a nested form.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/3cc9320ccabce57b. Report an issue: GitHub.