private ExternalJavacProcessHandler launchExternalJavacProcess(final String sdkHomePath,
                                                                 int heapSize,
                                                                 int port,
                                                                 File workingDir,
                                                                 Iterable<String> vmOptions,
                                                                 JavaCompilingTool compilingTool,
                                                                 final boolean keepProcessAlive) throws Exception {
    final UUID processId = UUID.randomUUID();
    final List<String> cmdLine = new ArrayList<>();

    final WslToLinuxPathConverter wslConverter = WslToLinuxPathConverter.createFrom(sdkHomePath);
    final boolean launchWSL = wslConverter != null;
    final ExternalJavacMessageHandler.WslSupport wslSupport = launchWSL? wslConverter : ExternalJavacMessageHandler.WslSupport.DIRECT;
    appendParam(cmdLine, wslSupport.convertPath(sdkHomePath + "/bin/java"));
    appendParam(cmdLine, "-Djava.awt.headless=true");

    //appendParam(cmdLine, "-XX:MaxPermSize=150m");
    if (heapSize > 0) {
      // if the value is zero or negative, use JVM default memory settings
      final int xms = heapSize / 2;
      if (xms > 32) {
        appendParam(cmdLine, "-Xms" + xms + "m");
      }
      appendParam(cmdLine, "-Xmx" + heapSize + "m");
    }

    // debugging
    //appendParam(cmdLine, "-XX:+HeapDumpOnOutOfMemoryError");
    //appendParam(cmdLine, "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5009");

    // javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language
    copyProperty(cmdLine, "file.encoding");
    copyProperty(cmdLine, "user.language");
    copyProperty(cmdLine, "user.country");
    copyProperty(cmdLine, "user.region");

    copyProperty(cmdLine, "io.netty.noUnsafe");

    appendParam(cmdLine, "-D" + ExternalJavacProcess.JPS_JAVA_COMPILING_TOOL_PROPERTY + "=" + compilingTool.getId());

    for (String option : vmOptions) {
      appendParam(cmdLine, option);
    }

    appendParam(cmdLine, "-classpath");
    List<File> cp = ClasspathBootstrap.getExternalJavacProcessClasspath(sdkHomePath, compilingTool);
    String pathSeparator = launchWSL? ":" : File.pathSeparator;
    String classpath = String.join(pathSeparator, Iterators.map(cp, f -> wslSupport.convertPath(f.getPath())));
    if (launchWSL && !classpath.isEmpty()) {
      cmdLine.add("'" + classpath.replace("'", "\\'") + "'");
    }
    else {
      appendParam(cmdLine, classpath);
    }

    appendParam(cmdLine, ExternalJavacProcess.class.getName());
    appendParam(cmdLine, processId.toString());
    InetAddress targetAddress = myListenAddress;
    if (targetAddress == null) {
      targetAddress = InetAddress.getLoopbackAddress();
    }
    appendParam(cmdLine, targetAddress.getHostAddress());
    appendParam(cmdLine, Integer.toString(port));
    appendParam(cmdLine, Boolean.toString(keepProcessAlive));  // keep in memory after build finished

    if (launchWSL) {
      String command =
        "\"cd '" + wslSupport.convertPath(workingDir.getPath()) + "' && " + String.join(" ", cmdLine) + "\"";
      cmdLine.clear();
      cmdLine.add(myWslExePath);
      cmdLine.add("--distribution");
      cmdLine.add(wslConverter.getDistributionId());
      cmdLine.add("--exec");
      cmdLine.add("/bin/sh");
      cmdLine.add("-c");
      cmdLine.add(command);
    }

    debug(()-> "starting external compiler: " + cmdLine);
    FileUtil.createDirectory(workingDir);

    final int processHash = processHash(sdkHomePath, vmOptions, compilingTool);
    final ProcessBuilder processBuilder = new ProcessBuilder(cmdLine);
    if (!launchWSL) {
      processBuilder.directory(workingDir);
    }
    final ExternalJavacProcessHandler processHandler = createProcessHandler(processId, processBuilder.start(), String.join(" ", cmdLine), keepProcessAlive);
    WSL_SUPPORT.set(processHandler, wslSupport);
    PROCESS_HASH.set(processHandler, processHash);
    processHandler.lock();
    myRunningProcesses.put(processId, processHandler);
    debug(()-> "external compiler process registered: id=" + processId + ", hash=" + processHash);
    processHandler.addProcessListener(this);
    processHandler.startNotify();
    return processHandler;
  }
private ExternalJavacProcessHandler launchExternalJavacProcess(final String sdkHomePath,
                                                                 int heapSize,
                                                                 int port,
                                                                 File workingDir,
                                                                 Iterable<String> vmOptions,
                                                                 JavaCompilingTool compilingTool,
                                                                 final boolean keepProcessAlive)