changeset 1681:21febc51839a

Merge.
author Doug Simon <doug.simon@oracle.com>
date Wed, 13 Apr 2016 11:14:00 +0200
parents 084f68e2f61d ba21793a0e48
children 38a1ce3aa59c
files src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/swt.js
diffstat 13 files changed, 211 insertions(+), 172 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Apr 07 21:51:44 2016 +0200
+++ b/.hgtags	Wed Apr 13 11:14:00 2016 +0200
@@ -346,3 +346,4 @@
 9937077e48f19e98af07c4954790fe09b94ca510 jdk-9+110
 133ea8746b37739a0510c80b42888bd85ace9477 jdk-9+111
 c261f8440c5578b34596e6b0419a81aec431a884 jdk-9+112
+a5d1990fd32d908da8154d79116fce8013ba4d40 jdk-9+113
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/base.js	Thu Apr 07 21:51:44 2016 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/base.js	Wed Apr 13 11:14:00 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,135 +23,92 @@
  * questions.
  */
 
-var JFX_BASE_CLASSES     = [];
-var JFX_GRAPHICS_CLASSES = [];
-var JFX_CONTROLS_CLASSES = [];
-var JFX_FXML_CLASSES     = [];
-var JFX_WEB_CLASSES      = [];
-var JFX_MEDIA_CLASSES    = [];
-var JFX_SWING_CLASSES    = [];
-var JFX_SWT_CLASSES      = [];
+var JFX_CLASSES = {
+    "javafx.base": [],
+    "javafx.controls": [],
+    "javafx.deploy": [],
+    "javafx.fxml": [],
+    "javafx.graphics": [],
+    "javafx.media": [],
+    "javafx.swing": [],
+    "javafx.web": []
+};
 
-function LOAD_FX_CLASSES(clsList) {
-    for each (var cls in clsList) {
-        // Ex. Stage = Java.type("javafx.stage.Stage");
-        this[cls[cls.length - 1]] = Java.type(cls.join("."));
+function LOAD_FX_CLASSES(global, module) {
+    if (JFX_CLASSES[module]) {
+        for each (var cls in JFX_CLASSES[module]) {
+            // Ex. Stage = Java.type("javafx.stage.Stage");
+            var name = cls.join(".");
+            var type = Java.type(name);
+            global[cls[cls.length - 1]] = type;
+        }
+
+        JFX_CLASSES[module] = undefined;
     }
 }
 
 (function() {
-    var System           = Java.type("java.lang.System");
-    var ZipFile          = Java.type("java.util.zip.ZipFile");
+    var Files = Java.type("java.nio.file.Files");
+    var FileSystems = Java.type("java.nio.file.FileSystems");
+    var FileVisitor = Java.type("java.nio.file.FileVisitor");
+    var FileVisitResult = Java.type("java.nio.file.FileVisitResult");
+    var CONTINUE = FileVisitResult.CONTINUE;
+    var SKIP_SUBTREE = FileVisitResult.SKIP_SUBTREE;
 
-    var SUFFIX_LENGTH    = ".class".length;
+    var URI = Java.type("java.net.URI");
+    var uri = new URI("jrt:/");
+    var jrtfs = FileSystems.getFileSystem(uri);
+    var rootDirectories = jrtfs.getRootDirectories();
 
-    // TODO - temporary patch until fx is moved to module system.
-    // <patch>
-    var jfxrtJar;
-    try {
-        jfxrtJar = new ZipFile(System.getProperty("java.home") + "/lib/jfxrt.jar");
-    } catch (ex1) {
-        try {
-            jfxrtJar = new ZipFile(System.getProperty("java.home") + "/lib/ext/jfxrt.jar");
-        } catch (ex2) {
-            throw new Error("JavaFX runtime not found");
+    var JRTFSWalker = Java.extend(FileVisitor, {
+        preVisitDirectory: function(path, attrs) {
+            var name = path.toString();
+
+            if (name.startsWith("/packages")) {
+                 return SKIP_SUBTREE;
+            }
+
+            if (name.startsWith("/modules") && !name.equals("/modules") && !name.startsWith("/modules/javafx")) {
+                return SKIP_SUBTREE;
+            }
+
+            return CONTINUE;
+        },
+
+        postVisitDirectory: function(path, attrs) {
+            return CONTINUE;
+        },
+
+        visitFile: function(file, attrs) {
+            var name = file.toString();
+
+            if (!name.endsWith(".class") || name.endsWith("module-info.class")) {
+                return CONTINUE;
+            }
+
+            var parts = name.split("/");
+            parts = parts.slice(2);
+            var module = parts.shift();
+            var path = parts;
+            var cls = path.pop();
+            cls = cls.substring(0, cls.length() - 6);
+            path.push(cls);
+
+            if (path[0] !== "javafx" || /\$\d+$/.test(cls)) {
+                return CONTINUE;
+            }
+
+            JFX_CLASSES[module].push(path);
+
+            return CONTINUE;
+        },
+
+        visitFileFailed: function(file, ex) {
+            return CONTINUE;
         }
-    }
-    // </patch>
+    });
 
-    var entries = jfxrtJar.entries();
-
-    while (entries.hasMoreElements()) {
-        var entry = entries.nextElement();
-
-        if (entry.isDirectory()) {
-            continue;
-        }
-
-        var name = entry.name;
-
-        if (!name.endsWith(".class")) {
-            continue;
-        }
-
-        name = name.substring(0, name.length - SUFFIX_LENGTH);
-        cls = name.split("/");
-
-        if (cls[0] != "javafx") {
-            continue;
-        }
-
-        var last = cls[cls.length - 1];
-        var nested = last.lastIndexOf("$");
-
-        // If class name ends with $nnn
-        if (nested != -1 && !(last.substring(nested) - 0)) {
-            continue;
-        }
-
-        switch (cls[1]) {
-        case "stage":
-            if (cls[2] == "Stage") {
-                JFX_BASE_CLASSES.push(cls);
-            } else {
-                JFX_GRAPHICS_CLASSES.push(cls);
-            }
-            break;
-
-        case "scene":
-            switch (cls[2]) {
-            case "Scene":
-            case "Group":
-                JFX_BASE_CLASSES.push(cls);
-                break;
-
-            case "chart":
-            case "control":
-                JFX_CONTROLS_CLASSES.push(cls);
-                break;
-
-            case "web":
-                JFX_WEB_CLASSES.push(cls);
-                break;
-
-            case "media":
-                JFX_MEDIA_CLASSES.push(cls);
-                break;
-
-            default:
-                JFX_GRAPHICS_CLASSES.push(cls);
-                break;
-            }
-            break;
-
-        case "beans":
-        case "collections":
-        case "events":
-        case "util":
-            JFX_BASE_CLASSES.push(cls);
-            break;
-
-        case "animation":
-        case "application":
-        case "concurrent":
-        case "css":
-        case "geometry":
-            JFX_GRAPHICS_CLASSES.push(cls);
-            break;
-
-        case "fxml":
-            JFX_FXML_CLASSES.push(cls);
-            break;
-
-        case "embed":
-            if (cls[2] == "swing") {
-                JFX_SWING_CLASSES.push(cls);
-            } else {
-                JFX_SWT_CLASSES.push(cls);
-            }
-            break;
-        }
-    }
+    Files.walkFileTree(rootDirectories[0], new JRTFSWalker());
 })();
 
-LOAD_FX_CLASSES(JFX_BASE_CLASSES);
+LOAD_FX_CLASSES(this, "javafx.base");
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/bootstrap.js	Thu Apr 07 21:51:44 2016 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/bootstrap.js	Wed Apr 13 11:14:00 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -30,7 +30,7 @@
 }
 
 // Extend the javafx.application.Application class overriding init, start and stop.
-com.sun.javafx.application.LauncherImpl.launchApplication((Java.extend(javafx.application.Application, {
+javafx.application.Application.launch((Java.extend(javafx.application.Application, {
     // Overridden javafx.application.Application.init();
     init: function() {
         // Java FX packages and classes must be defined here because
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/controls.js	Thu Apr 07 21:51:44 2016 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/controls.js	Wed Apr 13 11:14:00 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,8 +23,8 @@
  * questions.
  */
 
-if (!this.JFX_BASE_CLASSES) {
+if (!this.JFX_CLASSES) {
     load("fx:base.js")
 }
 
-LOAD_FX_CLASSES(JFX_CONTROLS_CLASSES);
+LOAD_FX_CLASSES(this, "javafx.controls");
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/fxml.js	Thu Apr 07 21:51:44 2016 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/fxml.js	Wed Apr 13 11:14:00 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,8 +23,8 @@
  * questions.
  */
 
-if (!this.JFX_BASE_CLASSES) {
+if (!this.JFX_CLASSES) {
     load("fx:base.js")
 }
 
-LOAD_FX_CLASSES(JFX_FXML_CLASSES);
+LOAD_FX_CLASSES(this, "javafx.fxml");
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/graphics.js	Thu Apr 07 21:51:44 2016 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/graphics.js	Wed Apr 13 11:14:00 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,10 +23,10 @@
  * questions.
  */
 
-if (!this.JFX_BASE_CLASSES) {
+if (!this.JFX_CLASSES) {
     load("fx:base.js")
 }
 
-LOAD_FX_CLASSES(JFX_GRAPHICS_CLASSES);
+LOAD_FX_CLASSES(this, "javafx.graphics");
 
 
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/media.js	Thu Apr 07 21:51:44 2016 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/media.js	Wed Apr 13 11:14:00 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,8 +23,8 @@
  * questions.
  */
 
-if (!this.JFX_BASE_CLASSES) {
+if (!this.JFX_CLASSES) {
     load("fx:base.js")
 }
 
-LOAD_FX_CLASSES(JFX_MEDIA_CLASSES);
+LOAD_FX_CLASSES(this, "javafx.media");
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/swing.js	Thu Apr 07 21:51:44 2016 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/swing.js	Wed Apr 13 11:14:00 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,8 +23,8 @@
  * questions.
  */
 
-if (!this.JFX_BASE_CLASSES) {
+if (!this.JFX_CLASSES) {
     load("fx:base.js")
 }
 
-LOAD_FX_CLASSES(JFX_SWING_CLASSES);
+LOAD_FX_CLASSES(this, "javafx.swing");
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/swt.js	Thu Apr 07 21:51:44 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-if (!this.JFX_BASE_CLASSES) {
-    load("fx:base.js")
-}
-
-LOAD_FX_CLASSES(JFX_SWT_CLASSES);
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/web.js	Thu Apr 07 21:51:44 2016 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/fx/web.js	Wed Apr 13 11:14:00 2016 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,8 +23,8 @@
  * questions.
  */
 
-if (!this.JFX_BASE_CLASSES) {
+if (!this.JFX_CLASSES) {
     load("fx:base.js")
 }
 
-LOAD_FX_CLASSES(JFX_WEB_CLASSES);
+LOAD_FX_CLASSES(this, "javafx.web");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8026249.js	Wed Apr 13 11:14:00 2016 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8026249: Cover several fuzzing test cases.
+ *
+ * @test
+ * @run
+ */
+
+function f1() { if(x3, y) x; }
+
+function f2(x) { return y, x }
+
+function q() { L: {{break L; } return; } }
+function q() { L: {if(x2) {break L; } throw x; } }
+
+function r() { switch(x) { default: if(true) break; return; } }
+function r() { switch(x) { default: L: break; return; } }
+
+function f4() { with({}) return eval("arguments", 3/0); }
+try { f4() } catch(e) { e.printStackTrace() }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8028429.js	Wed Apr 13 11:14:00 2016 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8028429: Check that a variable-arity call site passes arguments correctly
+ * after becoming megamorphic.
+ *
+ * @test
+ * @run
+ */
+
+ var fns = [
+    function(x) { print("0: " + x) },
+    function(x) { print("1: " + x) },
+    function(x) { print("2: " + x) },
+    function(x) { print("3: " + x) },
+    function(x) { print("4: " + x) },
+    function(x) { print("5: " + x) },
+    function(x) { print("6: " + x) },
+    function(x) { print("7: " + x) },
+    function(x) { print("8: " + x) }, // beyond unstable link threshold
+]
+
+for(var i = 0; i < fns.length; ++i) {
+    fns[i](0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,
+           23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,
+           43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,
+           63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,
+           83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,
+           102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,
+           117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,
+           132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,
+           147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,
+           162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,
+           177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
+           192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
+           207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,
+           222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,
+           237,238,239,240,241,242,243,244,245,246,247,248,249,250,251)
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8028429.js.EXPECTED	Wed Apr 13 11:14:00 2016 +0200
@@ -0,0 +1,9 @@
+0: 0
+1: 0
+2: 0
+3: 0
+4: 0
+5: 0
+6: 0
+7: 0
+8: 0