public void save(@NotNull final OutputFileObject fileObject) {
      if (JavaFileObject.Kind.CLASS != fileObject.getKind()) {
        // generated sources or resources must be saved synchronously, because some compilers (e.g.
        // eclipse)
        // may want to read generated text for further compilation
        try {
          final BinaryContent content = fileObject.getContent();
          if (content != null) {
            content.saveToFile(fileObject.getFile());
          }
        } catch (IOException e) {
          myContext.processMessage(
              new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, e.getMessage()));
        }
      }

      submitAsyncTask(
          myContext,
          new Runnable() {
            public void run() {
              try {
                for (ClassPostProcessor processor : ourClassProcessors) {
                  processor.process(myContext, fileObject);
                }
              } finally {
                myDelegateOutputFileSink.save(fileObject);
              }
            }
          });
    }
 private static int findFreePort() {
   try {
     final ServerSocket serverSocket = new ServerSocket(0);
     try {
       return serverSocket.getLocalPort();
     } finally {
       // workaround for linux : calling close() immediately after opening socket
       // may result that socket is not closed
       synchronized (serverSocket) {
         try {
           serverSocket.wait(1);
         } catch (Throwable ignored) {
         }
       }
       serverSocket.close();
     }
   } catch (IOException e) {
     e.printStackTrace(System.err);
     return JavacServer.DEFAULT_SERVER_PORT;
   }
 }