8048146: sjavac uses unexpected exit code of -1
authoralundblad
Tue, 22 Mar 2016 13:14:12 +0100
changeset 37643 626e07816dce
parent 37642 1ce8d55fac67
child 37644 33cf53901cac
8048146: sjavac uses unexpected exit code of -1 Summary: Changed exit codes for sjavac Reviewed-by: jlahoda
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/ClientMain.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/CompilationService.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/PooledSjavac.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/CompilationSubResult.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/IdleResetSjavac.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/RequestHandler.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/ServerMain.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/Sjavac.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java
langtools/test/tools/sjavac/HiddenFiles.java
langtools/test/tools/sjavac/IdleShutdown.java
langtools/test/tools/sjavac/IncludeExcludePatterns.java
langtools/test/tools/sjavac/PooledExecution.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java	Tue Mar 22 13:14:12 2016 +0100
@@ -26,8 +26,6 @@
 package com.sun.tools.sjavac;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -42,9 +40,8 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
-import java.util.regex.Pattern;
-import java.util.stream.Stream;
 
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.comp.CompilationService;
 import com.sun.tools.sjavac.options.Options;
 import com.sun.tools.sjavac.pubapi.PubApi;
@@ -283,7 +280,7 @@
             }
 
             // Check the return values.
-            if (subResult.returnCode != 0) {
+            if (subResult.result != Result.OK) {
                 rc = false;
             }
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/ClientMain.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/ClientMain.java	Tue Mar 22 13:14:12 2016 +0100
@@ -28,6 +28,8 @@
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.AutoFlushWriter;
 import com.sun.tools.sjavac.Log;
 import com.sun.tools.sjavac.Util;
@@ -58,7 +60,7 @@
             options = Options.parseArgs(args);
         } catch (IllegalArgumentException e) {
             Log.error(e.getMessage());
-            return -1;
+            return Result.CMDERR.exitCode;
         }
 
         Log.setLogLevel(options.getLogLevel());
@@ -73,13 +75,13 @@
         Sjavac sjavac = useServer ? new SjavacClient(options) : new SjavacImpl();
 
         // Perform compilation
-        int rc = sjavac.compile(args);
+        Result result = sjavac.compile(args);
 
         // If sjavac is running in the foreground we should shut it down at this point
         if (!useServer) {
             sjavac.shutdown();
         }
 
-        return rc;
+        return result.exitCode;
     }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java	Tue Mar 22 13:14:12 2016 +0100
@@ -26,23 +26,20 @@
 package com.sun.tools.sjavac.client;
 
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
-import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.Reader;
-import java.io.Writer;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Scanner;
-import java.util.stream.Stream;
 
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.Log;
 import com.sun.tools.sjavac.Util;
 import com.sun.tools.sjavac.options.OptionHelper;
@@ -116,8 +113,8 @@
     }
 
     @Override
-    public int compile(String[] args) {
-        int result = -1;
+    public Result compile(String[] args) {
+        Result result = null;
         try (Socket socket = tryConnect()) {
             PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
             BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
@@ -150,22 +147,28 @@
                 }
 
                 if (type.equals(SjavacServer.LINE_TYPE_RC)) {
-                    result = Integer.parseInt(content);
+                    result = Main.Result.valueOf(content);
                 }
             }
         } catch (PortFileInaccessibleException e) {
             Log.error("Port file inaccessible.");
-            result = CompilationSubResult.ERROR_FATAL;
+            result = Result.ERROR;
         } catch (IOException ioe) {
             Log.error("IOException caught during compilation: " + ioe.getMessage());
             Log.debug(ioe);
-            result = CompilationSubResult.ERROR_FATAL;
+            result = Result.ERROR;
         } catch (InterruptedException ie) {
             Thread.currentThread().interrupt(); // Restore interrupt
             Log.error("Compilation interrupted.");
             Log.debug(ie);
-            result = CompilationSubResult.ERROR_FATAL;
+            result = Result.ERROR;
         }
+
+        if (result == null) {
+            // No LINE_TYPE_RC was found.
+            result = Result.ERROR;
+        }
+
         return result;
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/CompilationService.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/CompilationService.java	Tue Mar 22 13:14:12 2016 +0100
@@ -42,6 +42,8 @@
 
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Dependencies;
 import com.sun.tools.javac.util.ListBuffer;
@@ -80,7 +82,7 @@
             Dependencies.GraphDependencies.preRegister(context);
 
             // Now setup the actual compilation
-            CompilationSubResult compilationResult = new CompilationSubResult(0);
+            CompilationSubResult compilationResult = new CompilationSubResult(Result.OK);
 
             // First deal with explicit source files on cmdline and in at file
             ListBuffer<JavaFileObject> explicitJFOs = new ListBuffer<>();
@@ -97,7 +99,7 @@
 
             // Create a log to capture compiler output
             StringWriter stderrLog = new StringWriter();
-            com.sun.tools.javac.main.Main.Result rc = com.sun.tools.javac.main.Main.Result.OK;
+            Result result;
             PublicApiCollector pubApiCollector = new PublicApiCollector(context, explicitJFOs);
             PathAndPackageVerifier papVerifier = new PathAndPackageVerifier();
             NewDependencyCollector depsCollector = new NewDependencyCollector(context, explicitJFOs);
@@ -120,20 +122,23 @@
                     task.addTaskListener(pubApiCollector);
                     task.addTaskListener(papVerifier);
                     logJavacInvocation(args);
-                    rc = task.doCall();
-                    Log.debug("javac returned with code " + rc);
+                    result = task.doCall();
+                    Log.debug("javac result: " + result);
                     sfm.flush();
+                } else {
+                    result = Result.ERROR;
                 }
             } catch (Exception e) {
                 Log.error(Util.getStackTrace(e));
                 stderrLog.append(Util.getStackTrace(e));
-                rc = com.sun.tools.javac.main.Main.Result.ERROR;
+                result = Result.ERROR;
             }
 
             compilationResult.packageArtifacts = sfm.getPackageArtifacts();
 
-            if (papVerifier.errorsDiscovered())
-                rc = com.sun.tools.javac.main.Main.Result.ERROR;
+            if (papVerifier.errorsDiscovered()) {
+                result = Result.ERROR;
+            }
 
             compilationResult.packageDependencies = depsCollector.getDependencies(false);
             compilationResult.packageCpDependencies = depsCollector.getDependencies(true);
@@ -141,7 +146,7 @@
             compilationResult.packagePubapis = pubApiCollector.getPubApis(true);
             compilationResult.dependencyPubapis = pubApiCollector.getPubApis(false);
             compilationResult.stderr = stderrLog.toString();
-            compilationResult.returnCode = rc.exitCode;
+            compilationResult.result = result;
 
             return compilationResult;
         } catch (IOException e) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/PooledSjavac.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/PooledSjavac.java	Tue Mar 22 13:14:12 2016 +0100
@@ -25,6 +25,7 @@
 
 package com.sun.tools.sjavac.comp;
 
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.Log;
 import com.sun.tools.sjavac.server.Sjavac;
 
@@ -54,7 +55,7 @@
     }
 
     @Override
-    public int compile(String[] args) {
+    public Result compile(String[] args) {
         Log log = Log.get();
         try {
             return pool.submit(() -> {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java	Tue Mar 22 13:14:12 2016 +0100
@@ -41,6 +41,7 @@
 
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.sjavac.JavacState;
 import com.sun.tools.sjavac.Log;
@@ -69,36 +70,36 @@
 public class SjavacImpl implements Sjavac {
 
     @Override
-    public int compile(String[] args) {
+    public Result compile(String[] args) {
         Options options;
         try {
             options = Options.parseArgs(args);
         } catch (IllegalArgumentException e) {
             Log.error(e.getMessage());
-            return RC_FATAL;
+            return Result.CMDERR;
         }
 
         if (!validateOptions(options))
-            return RC_FATAL;
+            return Result.CMDERR;
 
         if (srcDstOverlap(options.getSources(), options.getDestDir())) {
-            return RC_FATAL;
+            return Result.CMDERR;
         }
 
         if (!createIfMissing(options.getDestDir()))
-            return RC_FATAL;
+            return Result.ERROR;
 
         Path stateDir = options.getStateDir();
         if (stateDir != null && !createIfMissing(options.getStateDir()))
-            return RC_FATAL;
+            return Result.ERROR;
 
         Path gensrc = options.getGenSrcDir();
         if (gensrc != null && !createIfMissing(gensrc))
-            return RC_FATAL;
+            return Result.ERROR;
 
         Path hdrdir = options.getHeaderDir();
         if (hdrdir != null && !createIfMissing(hdrdir))
-            return RC_FATAL;
+            return Result.ERROR;
 
         if (stateDir == null) {
             // Prepare context. Direct logging to our byte array stream.
@@ -113,7 +114,7 @@
                                              .filter(arg -> !arg.startsWith(Option.SERVER.arg))
                                              .toArray(String[]::new);
             // Compile
-            Main.Result result = new Main("javac", printWriter).compile(passThroughArgs, context);
+            Result result = new Main("javac", printWriter).compile(passThroughArgs, context);
 
             // Process compiler output (which is always errors)
             printWriter.flush();
@@ -128,7 +129,7 @@
                     throw new UncheckedIOException(es);
                 }
             }
-            return result.exitCode;
+            return result;
 
         } else {
             // Load the prev build state database.
@@ -166,7 +167,7 @@
 
                 if (sources.isEmpty()) {
                     Log.error("Found nothing to compile!");
-                    return RC_FATAL;
+                    return Result.ERROR;
                 }
 
 
@@ -292,15 +293,15 @@
                     javac_state.removeSuperfluousArtifacts(recently_compiled);
                 }
 
-                return rc[0] ? RC_OK : RC_FATAL;
+                return rc[0] ? Result.OK : Result.ERROR;
             } catch (ProblemException e) {
                 // For instance make file list mismatch.
                 Log.error(e.getMessage());
                 Log.debug(e);
-                return RC_FATAL;
+                return Result.ERROR;
             } catch (Exception e) {
                 Log.error(e);
-                return RC_FATAL;
+                return Result.ERROR;
             }
         }
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/CompilationSubResult.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/CompilationSubResult.java	Tue Mar 22 13:14:12 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.pubapi.PubApi;
 
 /**
@@ -44,10 +45,7 @@
 
     static final long serialVersionUID = 46739181113L;
 
-    // Return code constants
-    public final static int ERROR_FATAL = -1;
-
-    public int returnCode;
+    public Result result;
     public Map<String, Set<URI>> packageArtifacts = new HashMap<>();
     public Map<String, Map<String, Set<String>>> packageDependencies = new HashMap<>();
     public Map<String, Map<String, Set<String>>> packageCpDependencies = new HashMap<>();
@@ -56,11 +54,11 @@
     public String stdout = "";
     public String stderr = "";
 
-    public CompilationSubResult(int returnCode) {
-        this.returnCode = returnCode;
+    public CompilationSubResult(Result result) {
+        this.result = result;
     }
 
-    public void setReturnCode(int returnCode) {
-        this.returnCode = returnCode;
+    public void setResult(Result result) {
+        this.result = result;
     }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/IdleResetSjavac.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/IdleResetSjavac.java	Tue Mar 22 13:14:12 2016 +0100
@@ -25,11 +25,9 @@
 
 package com.sun.tools.sjavac.server;
 
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.Log;
 
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
 import java.util.Timer;
 import java.util.TimerTask;
 
@@ -66,7 +64,7 @@
     }
 
     @Override
-    public int compile(String[] args) {
+    public Result compile(String[] args) {
         startCall();
         try {
             return delegate.compile(args);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/RequestHandler.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/RequestHandler.java	Tue Mar 22 13:14:12 2016 +0100
@@ -25,6 +25,7 @@
 
 package com.sun.tools.sjavac.server;
 
+import com.sun.tools.javac.main.Main;
 import com.sun.tools.sjavac.Log;
 import com.sun.tools.sjavac.Util;
 
@@ -100,10 +101,10 @@
             checkInternalErrorLog();
 
             // Perform compilation
-            int rc = sjavac.compile(args);
+            Main.Result rc = sjavac.compile(args);
 
             // Send return code back to client
-            out.println(LINE_TYPE_RC + ":" + rc);
+            out.println(LINE_TYPE_RC + ":" + rc.name());
 
             // Check for internal errors again.
             checkInternalErrorLog();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/ServerMain.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/ServerMain.java	Tue Mar 22 13:14:12 2016 +0100
@@ -32,6 +32,8 @@
 import java.io.PrintStream;
 import java.lang.Thread.UncaughtExceptionHandler;
 
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.Log;
 import com.sun.tools.sjavac.Log.Level;
 import com.sun.tools.sjavac.server.log.LazyInitFileLog;
@@ -75,7 +77,7 @@
         // Any options other than --startserver?
         if (args.length > 1) {
             Log.error("When spawning a background server, only a single --startserver argument is allowed.");
-            return 1;
+            return Result.CMDERR.exitCode;
         }
 
         int exitCode;
@@ -84,7 +86,7 @@
             exitCode = server.startServer();
         } catch (IOException | InterruptedException ex) {
             ex.printStackTrace();
-            exitCode = -1;
+            exitCode = Result.ERROR.exitCode;
         }
 
         return exitCode;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/Sjavac.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/Sjavac.java	Tue Mar 22 13:14:12 2016 +0100
@@ -25,6 +25,8 @@
 
 package com.sun.tools.sjavac.server;
 
+import com.sun.tools.javac.main.Main.Result;
+
 import java.io.Writer;
 
 
@@ -38,10 +40,6 @@
  *  deletion without notice.</b>
  */
 public interface Sjavac {
-
-    final static int RC_FATAL = -1;
-    final static int RC_OK = 0;
-
-    int compile(String[] args);
+    Result compile(String[] args);
     void shutdown();
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java	Tue Mar 22 13:14:12 2016 +0100
@@ -40,6 +40,8 @@
 import java.util.Random;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.Log;
 import com.sun.tools.sjavac.Util;
 import com.sun.tools.sjavac.client.PortFileInaccessibleException;
@@ -167,7 +169,7 @@
             if (portFile.containsPortInfo()) {
                 Log.debug("Javac server not started because portfile exists!");
                 portFile.unlock();
-                return -1;
+                return Result.ERROR.exitCode;
             }
 
             //           .-----------.   .--------.   .------.
@@ -221,7 +223,7 @@
         // Shut down
         sjavac.shutdown();
 
-        return 0;
+        return Result.OK.exitCode;
     }
 
     @Override
--- a/langtools/test/tools/sjavac/HiddenFiles.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/test/tools/sjavac/HiddenFiles.java	Tue Mar 22 13:14:12 2016 +0100
@@ -36,6 +36,7 @@
  * @run main Wrapper HiddenFiles
  */
 
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.sjavac.server.Sjavac;
 
@@ -62,6 +63,6 @@
                          "-d", BIN.toString(),
                          "--state-dir=" + STATE_DIR);
 
-        Assert.check(rc == Sjavac.RC_FATAL, "Compilation succeeded unexpectedly.");
+        Assert.check(rc == Result.ERROR.exitCode, "Compilation succeeded unexpectedly.");
     }
 }
--- a/langtools/test/tools/sjavac/IdleShutdown.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/test/tools/sjavac/IdleShutdown.java	Tue Mar 22 13:14:12 2016 +0100
@@ -29,9 +29,9 @@
  * @build Wrapper
  * @run main Wrapper IdleShutdown
  */
-import java.io.Writer;
 import java.util.concurrent.atomic.AtomicLong;
 
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.server.IdleResetSjavac;
 import com.sun.tools.sjavac.server.Sjavac;
 import com.sun.tools.sjavac.server.Terminable;
@@ -103,13 +103,13 @@
         public void shutdown() {
         }
         @Override
-        public int compile(String[] args) {
+        public Result compile(String[] args) {
             // Attempt to trigger idle timeout during a call by sleeping
             try {
                 Thread.sleep(TIMEOUT_MS + 1000);
             } catch (InterruptedException e) {
             }
-            return 0;
+            return Result.OK;
         }
     }
 }
--- a/langtools/test/tools/sjavac/IncludeExcludePatterns.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/test/tools/sjavac/IncludeExcludePatterns.java	Tue Mar 22 13:14:12 2016 +0100
@@ -33,6 +33,7 @@
  * @run main Wrapper IncludeExcludePatterns
  */
 
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.sjavac.server.Sjavac;
 
@@ -131,7 +132,7 @@
         int rc = compile((Object[]) args.split(" "));
 
         // Compilation should always pass in these tests
-        Assert.check(rc == Sjavac.RC_OK, "Compilation failed unexpectedly.");
+        Assert.check(rc == Result.OK.exitCode, "Compilation failed unexpectedly.");
 
         // The resulting .class files should correspond to the visible source files
         Set<Path> result = allFilesInDir(BIN);
--- a/langtools/test/tools/sjavac/PooledExecution.java	Thu Apr 21 13:37:01 2016 -0700
+++ b/langtools/test/tools/sjavac/PooledExecution.java	Tue Mar 22 13:14:12 2016 +0100
@@ -30,12 +30,10 @@
  * @build Wrapper
  * @run main Wrapper PooledExecution
  */
-import java.io.PrintWriter;
-import java.io.Writer;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import com.sun.tools.sjavac.Log;
+import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.sjavac.comp.PooledSjavac;
 import com.sun.tools.sjavac.server.Sjavac;
 
@@ -111,7 +109,7 @@
             AtomicInteger activeRequests = new AtomicInteger(0);
 
             @Override
-            public int compile(String[] args) {
+            public Result compile(String[] args) {
                 leftToStart.countDown();
                 int numActiveRequests = activeRequests.incrementAndGet();
                 System.out.printf("Left to start: %2d / Currently active: %2d%n",
@@ -125,7 +123,7 @@
                 }
                 activeRequests.decrementAndGet();
                 System.out.println("Task completed");
-                return 0;
+                return Result.OK;
             }
 
             @Override