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) {
          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) {
            creatable = false;
          }
          else {
            if (!componentClass.hasDefaultPublicConstructor()) {
              creatable = false;
            }
          }
          if (!creatable) {
            componentClass = Utils.suggestReplacementClass(componentClass);
            componentType = Type.getType(componentClass.getDescriptor());
          }
        }
        catch (ClassNotFoundException | IOException e) {
          throw new CodeGenerationException(lwComponent.getId(), e.getMessage(), e);
        }
      }

      if (!lwComponent.isCustomCreate() || myIgnoreCustomCreation) {
        generator.newInstance(componentType);
        generator.dup();
        generator.invokeConstructor(componentType, Method.getMethod("void <init>()"));
        generator.storeLocal(componentLocal);

        generateFieldBinding(lwComponent, generator, componentLocal);
      }
      else {
        final String binding = lwComponent.getBinding();
        if (binding == null) {
          throw new CodeGenerationException(lwComponent.getId(),
                                            "Only components bound to fields can have custom creation code");
        }
        generator.loadThis();
        generator.getField(getMainClassType(), binding, Type.getType(myFieldDescMap.get(binding)));
        generator.storeLocal(componentLocal);
      }

      if (lwComponent instanceof LwContainer) {
        LwContainer lwContainer = (LwContainer) lwComponent;
        if (!lwContainer.isCustomCreate() || lwContainer.getComponentCount() > 0) {
          getComponentCodeGenerator(lwContainer).generateContainerLayout(lwContainer, generator, componentLocal);
        }
      }

      generateComponentProperties(lwComponent, componentClass, generator, componentLocal);

      // add component to parent
      if (!(lwComponent.getParent() instanceof LwRootContainer)) {
        final LayoutCodeGenerator parentCodeGenerator = getComponentCodeGenerator(lwComponent.getParent());
        if (lwComponent instanceof LwNestedForm) {
          componentLocal = getNestedFormComponent(generator, componentClass, componentLocal);
        }
        parentCodeGenerator.generateComponentLayout(lwComponent, generator, componentLocal, parentLocal, myClassName);
      }

      if (lwComponent instanceof LwContainer) {
        LwContainer container = (LwContainer) lwComponent;

        generateBorder(container, generator, componentLocal);

        for(int i=0; i<container.getComponentCount(); i++) {
          generateSetupCodeForComponent((LwComponent) container.getComponent(i), generator, componentLocal);
        }
      }
    }
private void generateSetupCodeForComponent(final LwComponent lwComponent,
                                               final GeneratorAdapter generator,
                                               final int parentLocal)