diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java index b9b039354d4..4e309210d1f 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java @@ -257,7 +257,7 @@ public class SjavacClient implements Sjavac { // serverProcess != null at this point. try { // Throws an IOException if no valid values materialize - portFile.waitForValidValues(); + portFile.waitForValidValues(serverProcess); } catch (IOException ex) { // Process was started, but server failed to initialize. This could // for instance be due to the JVM not finding the server class, diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java index 3bbdca22c4e..a4cda8383d5 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java @@ -232,7 +232,7 @@ public class PortFile { /** * Wait for the port file to contain values that look valid. */ - public void waitForValidValues() throws IOException, InterruptedException { + public void waitForValidValues(Process serverProcess) throws IOException, InterruptedException { final int MS_BETWEEN_ATTEMPTS = 500; long startTime = System.currentTimeMillis(); long timeout = startTime + getServerStartupTimeoutSeconds() * 1000; @@ -250,6 +250,9 @@ public class PortFile { if (System.currentTimeMillis() > timeout) { break; } + if (!serverProcess.isAlive()) { + throw new IOException("Server process terminated."); + } Thread.sleep(MS_BETWEEN_ATTEMPTS); } throw new IOException("No port file values materialized. Giving up after " +