@Override
  public RunProfileState getState(final @NotNull Executor executor, final @NotNull ExecutionEnvironment env) throws ExecutionException {
    final Module module = getModule();
    if (module == null) {
      throw new ExecutionException(DevKitBundle.message("run.configuration.no.module.specified"));
    }
    final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
    final Sdk jdk = rootManager.getSdk();
    if (jdk == null) {
      throw CantRunException.noJdkForModule(module);
    }

    final Sdk ideaJdk = IdeaJdk.findIdeaJdk(jdk);
    if (ideaJdk == null) {
      throw new ExecutionException(DevKitBundle.message("sdk.type.incorrect.common"));
    }
    String sandboxHome = ((Sandbox)ideaJdk.getSdkAdditionalData()).getSandboxHome();

    if (sandboxHome == null) {
      throw new ExecutionException(DevKitBundle.message("sandbox.no.configured"));
    }

    try {
      sandboxHome = new File(sandboxHome).getCanonicalPath();
    }
    catch (IOException e) {
      throw new ExecutionException(DevKitBundle.message("sandbox.no.configured"));
    }
    final String canonicalSandbox = sandboxHome;

    //copy license from running instance of idea
    IdeaLicenseHelper.copyIDEALicense(sandboxHome);

    return new JavaCommandLineState(env) {
      @Override
      protected JavaParameters createJavaParameters() throws ExecutionException {

        final JavaParameters params = new JavaParameters();

        ParametersList vm = params.getVMParametersList();

        fillParameterList(vm, VM_PARAMETERS);
        fillParameterList(params.getProgramParametersList(), PROGRAM_PARAMETERS);
        Sdk usedIdeaJdk = ideaJdk;
        String alternativeIdePath = getAlternativeJrePath();
        if (isAlternativeJreEnabled() && !StringUtil.isEmptyOrSpaces(alternativeIdePath)) {
          final Sdk configuredJdk = ProjectJdkTable.getInstance().findJdk(alternativeIdePath);
          if (configuredJdk != null) {
            usedIdeaJdk = configuredJdk;
          }
          else {
            try {
              usedIdeaJdk = usedIdeaJdk.clone();
            }
            catch (CloneNotSupportedException e) {
              throw new ExecutionException(e.getMessage());
            }
            final SdkModificator sdkToSetUp = usedIdeaJdk.getSdkModificator();
            sdkToSetUp.setHomePath(alternativeIdePath);
            ApplicationManager.getApplication().runWriteAction(sdkToSetUp::commitChanges);
          }
        }
        String ideaJdkHome = usedIdeaJdk.getHomePath();
        assert ideaJdkHome != null;

        boolean fromIdeaProject = PsiUtil.isPathToIntelliJIdeaSources(ideaJdkHome);

        vm.defineProperty(PathManager.PROPERTY_CONFIG_PATH, canonicalSandbox + File.separator + "config");
        vm.defineProperty(PathManager.PROPERTY_SYSTEM_PATH, canonicalSandbox + File.separator + "system");
        vm.defineProperty(PathManager.PROPERTY_PLUGINS_PATH, canonicalSandbox + File.separator + "plugins");

        if (!vm.hasProperty("jdk.module.illegalAccess.silent")) {
          vm.defineProperty("jdk.module.illegalAccess.silent", "true");
        }

        // use product-info.json values if found, otherwise fallback to defaults
        ProductInfo productInfo = ProductInfoKt.loadProductInfo(ideaJdkHome);

        if (productInfo != null && !productInfo.getAdditionalJvmArguments().isEmpty()) {
          productInfo.getAdditionalJvmArguments().forEach(vm::add);
        }
        else {
          String buildNumber = IdeaJdk.getBuildNumber(ideaJdkHome);
          if (buildNumber != null) {
            String versionString = StringUtil.substringAfter(buildNumber, "-");
            if (versionString != null) {
              Version version = Version.parseVersion(versionString);
              if (version != null && version.isOrGreaterThan(221)) {
                vm.defineProperty(JUnitDevKitPatcher.SYSTEM_CL_PROPERTY, "com.intellij.util.lang.PathClassLoader");
              }
            }
          }

          if (!vm.hasProperty(PlatformUtils.PLATFORM_PREFIX_KEY)) {
            if (buildNumber != null) {
              String prefix = IntelliJPlatformProduct.fromBuildNumber(buildNumber).getPlatformPrefix();
              if (prefix != null) {
                vm.defineProperty(PlatformUtils.PLATFORM_PREFIX_KEY, prefix);
              }
            }
          }

          Sdk internalJavaSdk = ObjectUtils.chooseNotNull(IdeaJdk.getInternalJavaSdk(usedIdeaJdk), usedIdeaJdk);
          var sdkVersion = ((JavaSdk)internalJavaSdk.getSdkType()).getVersion(jdk);
          if (sdkVersion != null && sdkVersion.isAtLeast(JavaSdkVersion.JDK_17)) {
            try (InputStream stream = PluginRunConfiguration.class.getResourceAsStream("/META-INF/OpenedPackages.txt")) {
              assert stream != null;
              JavaModuleOptions.readOptions(stream, OS.CURRENT).forEach(vm::add);
            }
            catch (IOException e) {
              throw new RuntimeException(e);
            }
          }
        }

        if (!vm.hasProperty(JetBrainsProtocolHandler.REQUIRED_PLUGINS_KEY) && PluginModuleType.isOfType(module)) {
          final String id = getPluginId(module);
          if (id != null) {
            vm.defineProperty(JetBrainsProtocolHandler.REQUIRED_PLUGINS_KEY, id);
          }
        }

        if (SystemInfo.isMac) {
          vm.defineProperty("apple.awt.fileDialogForDirectories", "true");
        }

        if (SystemInfo.isUnix && !SystemInfo.isMac) {
          if (VM_PARAMETERS == null || !VM_PARAMETERS.contains("-Dsun.awt.disablegrab")) {
            vm.defineProperty("sun.awt.disablegrab", "true"); // See http://devnet.jetbrains.net/docs/DOC-1142
          }
        }

        if (!vm.hasProperty(SlowOperations.IDEA_PLUGIN_SANDBOX_MODE)) {
          vm.defineProperty(SlowOperations.IDEA_PLUGIN_SANDBOX_MODE, "true");
        }

        params.setWorkingDirectory(ideaJdkHome + File.separator + "bin" + File.separator);

        params.setJdk(usedIdeaJdk);

        if (fromIdeaProject) {
          OrderEnumerator enumerator = OrderEnumerator.orderEntries(module).productionOnly().recursively();
          for (VirtualFile file : enumerator.getAllLibrariesAndSdkClassesRoots()) {
            params.getClassPath().add(file);
          }
        }
        else {
          for (String path : getJarFileNames(productInfo)) {
            params.getClassPath().add(ideaJdkHome + FileUtil.toSystemDependentName("/lib/" + path));
          }

          if (productInfo != null) {
            for (String moduleJarPath: productInfo.getProductModuleJarPaths()) {
              params.getClassPath().add(ideaJdkHome + FileUtil.toSystemIndependentName("/"+ moduleJarPath));
            }
          }
        }
        params.getClassPath().addFirst(((JavaSdkType)usedIdeaJdk.getSdkType()).getToolsPath(usedIdeaJdk));

        params.setMainClass("com.intellij.idea.Main");

        return params;
      }

      private static List<String> getJarFileNames(@Nullable ProductInfo productInfo) {
        if (productInfo != null && !productInfo.getBootClassPathJarNames().isEmpty()) {
          return productInfo.getBootClassPathJarNames();
        }

        return List.of(
          // log4j, jdom and trove4j needed for running on branch 202 and older
          "log4j.jar", "jdom.jar", "trove4j.jar",
          "openapi.jar", "util.jar", "util_rt.jar", "bootstrap.jar", "idea_rt.jar", "idea.jar",
          "3rd-party-rt.jar", "jna.jar");
      }
    };
  }
@Override
  public RunProfileState getState(final @NotNull Executor executor, final @NotNull ExecutionEnvironment env)