1.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Wed Apr 27 05:49:41 2016 +0200
1.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Wed Apr 27 06:13:59 2016 +0200
1.3 @@ -900,9 +900,19 @@
1.4
1.5 @Override
1.6 public void service(Request request, Response response) throws Exception {
1.7 - if ("true".equals(request.getParameter("exit"))) {
1.8 - LOG.info("Exit request received. Shutting down!");
1.9 - shutdown();
1.10 + final String exit = request.getParameter("exit");
1.11 + if (exit != null) {
1.12 + int exitCode = -1;
1.13 + try {
1.14 + exitCode = Integer.parseInt(exit);
1.15 + } catch (NumberFormatException ex) {
1.16 + exitCode = "true".equals(exit) ? 0 : -1;
1.17 + }
1.18 + if (exitCode != -1) {
1.19 + LOG.info("Exit request received. Shutting down!");
1.20 + shutdown();
1.21 + System.exit(exitCode);
1.22 + }
1.23 }
1.24 if (request.getRequestURI().equals(vmResource)) {
1.25 response.setCharacterEncoding("UTF-8");
2.1 --- a/rt/emul/compact/src/main/java/java/lang/System.java Wed Apr 27 05:49:41 2016 +0200
2.2 +++ b/rt/emul/compact/src/main/java/java/lang/System.java Wed Apr 27 06:13:59 2016 +0200
2.3 @@ -85,7 +85,12 @@
2.4 return "\n";
2.5 }
2.6
2.7 - @JavaScriptBody(args = { "exitCode" }, body = "window.close();")
2.8 + @JavaScriptBody(args = { "exitCode" }, body = ""
2.9 + + "var xhttp = new XMLHttpRequest();\n"
2.10 + + "xhttp.open('GET', '/?exit=' + exitCode, true);\n"
2.11 + + "xhttp.send();\n"
2.12 + + "window.close();\n"
2.13 + )
2.14 public static void exit(int exitCode) {
2.15 }
2.16