public ExternalJavacRunResult forkJavac(String javaHome,
                                          int heapSize,
                                          Iterable<String> vmOptions,
                                          Iterable<String> options,
                                          CompilationPaths paths,
                                          Iterable<? extends File> files,
                                          Map<File, Set<File>> outs,
                                          DiagnosticOutputConsumer diagnosticSink,
                                          OutputFileConsumer outputSink,
                                          JavaCompilingTool compilingTool,
                                          CanceledStatus cancelStatus, final boolean keepProcessAlive) {
    try {
      final ExternalJavacProcessHandler running = findRunningProcess(processHash(javaHome, vmOptions, compilingTool));
      final ExternalJavacProcessHandler processHandler = running != null? running : launchExternalJavacProcess(
        javaHome, heapSize, myListenPort, myWorkingDir, vmOptions, compilingTool, keepProcessAlive
      );

      final Channel channel = lookupChannel(processHandler.getProcessId());
      if (channel != null) {
        final ExternalJavacMessageHandler.WslSupport wslSupport = WSL_SUPPORT.get(processHandler);
        final ExternalJavacMessageHandler.WslSupport converter = wslSupport instanceof WslToLinuxPathConverter? ((WslToLinuxPathConverter)wslSupport).reverseConverter() : ExternalJavacMessageHandler.WslSupport.DIRECT;
        final CompileSession session = new CompileSession(
          processHandler.getProcessId(), new ExternalJavacMessageHandler(diagnosticSink, outputSink, getEncodingName(options), converter), cancelStatus
        );
        mySessions.put(session.getId(), session);
        channel.writeAndFlush(JavacProtoUtil.toMessage(session.getId(), JavacProtoUtil.createCompilationRequest(
          options, files, paths.getClasspath(), paths.getPlatformClasspath(), paths.getModulePath(), paths.getUpgradeModulePath(), paths.getSourcePath(), outs, wslSupport
        )));
        return session;
      }
      else {
        LOG.warn("Failed to connect to javac process");
      }
    }
    catch (Throwable e) {
      LOG.info(e);
      diagnosticSink.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, e.getMessage()));
    }
    return ExternalJavacRunResult.FAILURE;
  }
public ExternalJavacRunResult forkJavac(String javaHome,
                                          int heapSize,
                                          Iterable<String> vmOptions,
                                          Iterable<String> options,
                                          CompilationPaths paths,
                                          Iterable<? extends File> files,
                                          Map<File, Set<File>> outs,
                                          DiagnosticOutputConsumer diagnosticSink,
                                          OutputFileConsumer outputSink,
                                          JavaCompilingTool compilingTool,
                                          CanceledStatus cancelStatus, final boolean keepProcessAlive)