diff --git a/javafx-ui-common/src/com/sun/javafx/application/LauncherImpl.java b/javafx-ui-common/src/com/sun/javafx/application/LauncherImpl.java --- a/javafx-ui-common/src/com/sun/javafx/application/LauncherImpl.java +++ b/javafx-ui-common/src/com/sun/javafx/application/LauncherImpl.java @@ -7,6 +7,8 @@ import com.sun.javafx.jmx.SGMXBeanAccessor; import com.sun.javafx.runtime.SystemProperties; import java.lang.reflect.Constructor; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; @@ -198,6 +200,30 @@ }); } + // RT-15601: workaround for Mac crash / hang on exit + boolean isMac = System.getProperty("os.name").startsWith("Mac"); + if (isMac) { + boolean keepAlive = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Boolean run() { + return Boolean.getBoolean("javafx.keepalive"); + } + }); + if (!keepAlive) { + if (constructorError != null) { + constructorError.printStackTrace(); + } else if (initError != null) { + initError.printStackTrace(); + } else if(startError != null) { + startError.printStackTrace(); + } else if (stopError != null) { + stopError.printStackTrace(); + } + System.err.println("JavaFX application launcher: calling System.exit"); + System.exit(0); + } + } + // END OF WORKAROUND + if (error) { if (constructorError != null) { throw new RuntimeException("Unable to construct Application instance: "