private static void configureJdk(Element cfg, @NotNull Module module) {
    String jdkName = cfg.getChildTextTrim("jdkName");
    if (StringUtil.isEmptyOrSpaces(jdkName)) return;

    ModuleRootManager rootManager = ModuleRootManager.getInstance(module);

    String currentSdkName = null;
    Sdk sdk = rootManager.getSdk();
    if (sdk != null) {
      currentSdkName = sdk.getName();
    }

    if (!jdkName.equals(currentSdkName)) {
      ModifiableRootModel model = rootManager.getModifiableModel();

      if (jdkName.equals(ProjectRootManager.getInstance(model.getProject()).getProjectSdkName())) {
        model.inheritSdk();
      }
      else {
        Sdk jdk = ProjectJdkTable.getInstance().findJdk(jdkName);
        if (jdk != null) {
          model.setSdk(jdk);
        }
        else {
          model.setInvalidSdk(jdkName, JavaSdk.getInstance().getName());
        }
      }

      if (ApplicationManager.getApplication().isDispatchThread()) {
        WriteAction.run(() ->
                          model.commit()
        );
      }
      else {
        ApplicationManager.getApplication().invokeAndWait(() -> {
          WriteAction.run(() ->
                            model.commit()
          );
        });
      }
    }
  }
private static void configureJdk(Element cfg, @NotNull Module module)