Wed, 03 Jun 2015 20:30:20 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions | |
src/jdk/nashorn/internal/runtime/JSObjectListAdapter.java | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Thu May 28 20:55:21 2015 -0700 1.2 +++ b/.hgtags Wed Jun 03 20:30:20 2015 -0700 1.3 @@ -422,3 +422,4 @@ 1.4 78fcf7f0eac8ffa474518b315bdf84a1dbd6e76d jdk8u60-b15 1.5 bf44ade6c2c2e697ccbc1e57f3eac870908614e6 jdk8u60-b16 1.6 ff7052ce0f6b655d726cd0f77e9a5f8313361889 jdk8u60-b17 1.7 +0b5c0f02a0b79ae0aa97520d65e5b520af8f1b2a jdk8u60-b18
2.1 --- a/make/build.xml Thu May 28 20:55:21 2015 -0700 2.2 +++ b/make/build.xml Wed Jun 03 20:30:20 2015 -0700 2.3 @@ -210,7 +210,7 @@ 2.4 </target> 2.5 2.6 <target name="javadoc" depends="jar"> 2.7 - <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="src/overview.html" 2.8 + <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${src.dir}/overview.html" 2.9 extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}" 2.10 additionalparam="-quiet" failonerror="true"> 2.11 <classpath> 2.12 @@ -460,7 +460,7 @@ 2.13 </testng> 2.14 </target> 2.15 2.16 - <target name="test" depends="test-pessimistic, test-optimistic"/> 2.17 + <target name="test" depends="javadoc, test-pessimistic, test-optimistic"/> 2.18 2.19 <target name="test-optimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 2.20 <echo message="Running test suite in OPTIMISTIC mode..."/>
3.1 --- a/samples/browser_dom.js Thu May 28 20:55:21 2015 -0700 3.2 +++ b/samples/browser_dom.js Wed Jun 03 20:30:20 2015 -0700 3.3 @@ -40,7 +40,6 @@ 3.4 var ChangeListener = Java.type("javafx.beans.value.ChangeListener"); 3.5 var Scene = Java.type("javafx.scene.Scene"); 3.6 var WebView = Java.type("javafx.scene.web.WebView"); 3.7 -var EventListener = Java.type("org.w3c.dom.events.EventListener"); 3.8 3.9 // JavaFX start method 3.10 function start(stage) {
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/samples/console.js Wed Jun 03 20:30:20 2015 -0700 4.3 @@ -0,0 +1,134 @@ 4.4 +/* 4.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 4.6 + * 4.7 + * Redistribution and use in source and binary forms, with or without 4.8 + * modification, are permitted provided that the following conditions 4.9 + * are met: 4.10 + * 4.11 + * - Redistributions of source code must retain the above copyright 4.12 + * notice, this list of conditions and the following disclaimer. 4.13 + * 4.14 + * - Redistributions in binary form must reproduce the above copyright 4.15 + * notice, this list of conditions and the following disclaimer in the 4.16 + * documentation and/or other materials provided with the distribution. 4.17 + * 4.18 + * - Neither the name of Oracle nor the names of its 4.19 + * contributors may be used to endorse or promote products derived 4.20 + * from this software without specific prior written permission. 4.21 + * 4.22 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 4.23 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 4.24 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 4.25 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 4.26 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 4.27 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 4.28 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 4.29 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 4.30 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 4.31 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 4.32 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4.33 + */ 4.34 + 4.35 +/** 4.36 + * Simple Web Console-like support for Nashorn. In addition to 4.37 + * Web console object methods, this console add methods of 4.38 + * java.io.Console as well. Note:not all web console methods are 4.39 + * implemented but useful subset is implemented. 4.40 + * 4.41 + * See also: https://developer.mozilla.org/en/docs/Web/API/console 4.42 + */ 4.43 + 4.44 + 4.45 +if (typeof console == 'undefined') { 4.46 + 4.47 +(function() { 4.48 + var LocalDateTime = Java.type("java.time.LocalDateTime"); 4.49 + var System = Java.type("java.lang.System"); 4.50 + var jconsole = System.console(); 4.51 + 4.52 + // add a new global variable called "console" 4.53 + this.console = { 4.54 + }; 4.55 + 4.56 + function addConsoleMethods() { 4.57 + // expose methods of java.io.Console as an extension 4.58 + var placeholder = "-*-"; 4.59 + // put a placeholder for each name from java.lang.Object 4.60 + var objMethods = Object.bindProperties({}, new java.lang.Object()); 4.61 + for (var m in objMethods) { 4.62 + console[m] = placeholder; 4.63 + } 4.64 + 4.65 + // bind only the methods of java.io.Console 4.66 + // This bind will skip java.lang.Object methods as console 4.67 + // has properties of same name. 4.68 + Object.bindProperties(console, jconsole); 4.69 + 4.70 + // Now, delete java.lang.Object methods 4.71 + for (var m in console) { 4.72 + if (console[m] == placeholder) { 4.73 + delete console[m]; 4.74 + } 4.75 + } 4.76 + } 4.77 + 4.78 + addConsoleMethods(); 4.79 + 4.80 + function consoleLog(type, msg) { 4.81 + // print type of message, then time. 4.82 + jconsole.format("%s [%s] ", type, LocalDateTime.now().toString()); 4.83 + if (typeof msg == 'string') { 4.84 + jconsole.format(msg + "\n", Array.prototype.slice.call(arguments, 2)); 4.85 + } else { 4.86 + // simple space separated values and newline at the end 4.87 + var arr = Array.prototype.slice.call(arguments, 1); 4.88 + jconsole.format("%s\n", arr.join(" ")); 4.89 + } 4.90 + } 4.91 + 4.92 + console.toString = function() "[object Console]"; 4.93 + 4.94 + // web console functions 4.95 + 4.96 + console.assert = function(expr) { 4.97 + if (! expr) { 4.98 + arguments[0] = "Assertion Failed:"; 4.99 + consoleLog.apply(console, arguments); 4.100 + // now, stack trace at the end 4.101 + jconsole.format("%s\n", new Error().stack); 4.102 + } 4.103 + }; 4.104 + 4.105 + // dummy clear to avoid error! 4.106 + console.clear = function() {}; 4.107 + 4.108 + var counter = { 4.109 + get: function(label) { 4.110 + if (! this[label]) { 4.111 + return this[label] = 1; 4.112 + } else { 4.113 + return ++this[label]; 4.114 + } 4.115 + } 4.116 + }; 4.117 + 4.118 + // counter 4.119 + console.count = function(label) { 4.120 + label = label? String(label) : "<no label>"; 4.121 + jconsole.format("%s: %d\n",label, counter.get(label).intValue()); 4.122 + } 4.123 + 4.124 + // logging 4.125 + console.error = consoleLog.bind(jconsole, "ERROR"); 4.126 + console.info = consoleLog.bind(jconsole, "INFO"); 4.127 + console.log = console.info; 4.128 + console.debug = console.log; 4.129 + console.warn = consoleLog.bind(jconsole, "WARNING"); 4.130 + 4.131 + // print stack trace 4.132 + console.trace = function() { 4.133 + jconsole.format("%s\n", new Error().stack); 4.134 + }; 4.135 +})(); 4.136 + 4.137 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/samples/consoleuse.js Wed Jun 03 20:30:20 2015 -0700 5.3 @@ -0,0 +1,55 @@ 5.4 +/* 5.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 5.6 + * 5.7 + * Redistribution and use in source and binary forms, with or without 5.8 + * modification, are permitted provided that the following conditions 5.9 + * are met: 5.10 + * 5.11 + * - Redistributions of source code must retain the above copyright 5.12 + * notice, this list of conditions and the following disclaimer. 5.13 + * 5.14 + * - Redistributions in binary form must reproduce the above copyright 5.15 + * notice, this list of conditions and the following disclaimer in the 5.16 + * documentation and/or other materials provided with the distribution. 5.17 + * 5.18 + * - Neither the name of Oracle nor the names of its 5.19 + * contributors may be used to endorse or promote products derived 5.20 + * from this software without specific prior written permission. 5.21 + * 5.22 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 5.23 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 5.24 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 5.25 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 5.26 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 5.27 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 5.28 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 5.29 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 5.30 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 5.31 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 5.32 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 5.33 + */ 5.34 + 5.35 +load(__DIR__ + "console.js"); 5.36 + 5.37 +console.log("consoleuse.js started!"); 5.38 + 5.39 +function func() { 5.40 + console.count("func"); 5.41 +} 5.42 + 5.43 + 5.44 +func(); 5.45 +func(); 5.46 +func(); 5.47 +func(); 5.48 + 5.49 +// java.io.Console method 5.50 +console.readPassword("passworld please: "); 5.51 +console.error("Big error: %s!", "you revealed your password!"); 5.52 +console.warn("You've done this %d times", 345); 5.53 +console.assert(arguments.length != 0, "no arguments!"); 5.54 + 5.55 +// java.io.Console methods 5.56 +var str = console.readLine("enter something: "); 5.57 +console.printf("you entered: %s\n", str); 5.58 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/samples/time_color.fx Wed Jun 03 20:30:20 2015 -0700 6.3 @@ -0,0 +1,89 @@ 6.4 +#// Usage: jjs -fx time_color.js [-- true/false] 6.5 + 6.6 +/* 6.7 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 6.8 + * 6.9 + * Redistribution and use in source and binary forms, with or without 6.10 + * modification, are permitted provided that the following conditions 6.11 + * are met: 6.12 + * 6.13 + * - Redistributions of source code must retain the above copyright 6.14 + * notice, this list of conditions and the following disclaimer. 6.15 + * 6.16 + * - Redistributions in binary form must reproduce the above copyright 6.17 + * notice, this list of conditions and the following disclaimer in the 6.18 + * documentation and/or other materials provided with the distribution. 6.19 + * 6.20 + * - Neither the name of Oracle nor the names of its 6.21 + * contributors may be used to endorse or promote products derived 6.22 + * from this software without specific prior written permission. 6.23 + * 6.24 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 6.25 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 6.26 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 6.27 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 6.28 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 6.29 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 6.30 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 6.31 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 6.32 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 6.33 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 6.34 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6.35 + */ 6.36 + 6.37 +// A simple javafx program that changes background color 6.38 +// of scene based on current time value (once per sec). 6.39 +// inspired by http://whatcolourisit.scn9a.org/ 6.40 + 6.41 +if (!$OPTIONS._fx) { 6.42 + print("Usage: jjs -fx time_color.js"); 6.43 + print(" jjs -fx time_color.js -- true"); 6.44 + exit(1); 6.45 +} 6.46 + 6.47 +// JavaFX classes used 6.48 +var Color = Java.type("javafx.scene.paint.Color"); 6.49 +var Group = Java.type("javafx.scene.Group"); 6.50 +var Label = Java.type("javafx.scene.control.Label"); 6.51 +var Platform = Java.type("javafx.application.Platform"); 6.52 +var Scene = Java.type("javafx.scene.Scene"); 6.53 +var Timer = Java.type("java.util.Timer"); 6.54 + 6.55 +// execute function periodically once per given time in millisec 6.56 +function setInterval(func, ms) { 6.57 + // New timer, run as daemon so the application can quit 6.58 + var timer = new Timer("setInterval", true); 6.59 + timer.schedule(function() Platform.runLater(func), ms, ms); 6.60 + return timer; 6.61 +} 6.62 + 6.63 +// do you want to flip hour/min/sec for RGB? 6.64 +var flip = arguments.length > 0? "true".equals(arguments[0]) : false; 6.65 + 6.66 +// JavaFX start method 6.67 +function start(stage) { 6.68 + start.title = "Time Color"; 6.69 + var root = new Group(); 6.70 + var label = new Label("time"); 6.71 + label.textFill = Color.WHITE; 6.72 + root.children.add(label); 6.73 + stage.scene = new Scene(root, 700, 500); 6.74 + 6.75 + setInterval(function() { 6.76 + var d = new Date(); 6.77 + var hours = d.getHours(); 6.78 + var mins = d.getMinutes(); 6.79 + var secs = d.getSeconds(); 6.80 + 6.81 + if (hours < 10) hours = "0" + hours; 6.82 + if (mins < 10) mins = "0" + mins; 6.83 + if (secs < 10) secs = "0" + secs; 6.84 + 6.85 + var hex = flip? 6.86 + "#" + secs + mins + hours : "#" + hours + mins + secs; 6.87 + label.text = "Color: " + hex; 6.88 + stage.scene.fill = Color.web(hex); 6.89 + }, 1000); 6.90 + 6.91 + stage.show(); 6.92 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/samples/undefined_call.js Wed Jun 03 20:30:20 2015 -0700 7.3 @@ -0,0 +1,48 @@ 7.4 +/* 7.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 7.6 + * 7.7 + * Redistribution and use in source and binary forms, with or without 7.8 + * modification, are permitted provided that the following conditions 7.9 + * are met: 7.10 + * 7.11 + * - Redistributions of source code must retain the above copyright 7.12 + * notice, this list of conditions and the following disclaimer. 7.13 + * 7.14 + * - Redistributions in binary form must reproduce the above copyright 7.15 + * notice, this list of conditions and the following disclaimer in the 7.16 + * documentation and/or other materials provided with the distribution. 7.17 + * 7.18 + * - Neither the name of Oracle nor the names of its 7.19 + * contributors may be used to endorse or promote products derived 7.20 + * from this software without specific prior written permission. 7.21 + * 7.22 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 7.23 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 7.24 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 7.25 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 7.26 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 7.27 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 7.28 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 7.29 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 7.30 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 7.31 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 7.32 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 7.33 + */ 7.34 + 7.35 +// Nashorn extension: __noSuchMethod__ 7.36 +// See also: https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions#Nashornextensions-__noSuchMethod__ 7.37 + 7.38 +Object.prototype.__noSuchMethod__ = function(name) { 7.39 + print(name + " function is not defined in " + this); 7.40 + 7.41 + // Nashorn extension: stack property 7.42 + // gives stack trace as a string 7.43 + print(new Error().stack); 7.44 +} 7.45 + 7.46 +function func(obj) { 7.47 + obj.foo(); 7.48 +} 7.49 + 7.50 +func({}); 7.51 +func(this);
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/samples/unzip.js Wed Jun 03 20:30:20 2015 -0700 8.3 @@ -0,0 +1,79 @@ 8.4 +/* 8.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 8.6 + * 8.7 + * Redistribution and use in source and binary forms, with or without 8.8 + * modification, are permitted provided that the following conditions 8.9 + * are met: 8.10 + * 8.11 + * - Redistributions of source code must retain the above copyright 8.12 + * notice, this list of conditions and the following disclaimer. 8.13 + * 8.14 + * - Redistributions in binary form must reproduce the above copyright 8.15 + * notice, this list of conditions and the following disclaimer in the 8.16 + * documentation and/or other materials provided with the distribution. 8.17 + * 8.18 + * - Neither the name of Oracle nor the names of its 8.19 + * contributors may be used to endorse or promote products derived 8.20 + * from this software without specific prior written permission. 8.21 + * 8.22 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 8.23 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 8.24 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 8.25 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 8.26 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 8.27 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 8.28 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 8.29 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 8.30 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 8.31 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 8.32 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 8.33 + */ 8.34 + 8.35 +/* 8.36 + * Simple unzip tool using #nashorn and #java 8.37 + * zip fs file system interface. 8.38 + */ 8.39 + 8.40 +if (arguments.length == 0) { 8.41 + print("Usage: jjs zipfs.js -- <.zip/.jar file> [out dir]"); 8.42 + exit(1); 8.43 +} 8.44 + 8.45 +var File = Java.type("java.io.File"); 8.46 +// output directory where zip is extracted 8.47 +var outDir = arguments[1]; 8.48 +if (!outDir) { 8.49 + outDir = "."; 8.50 +} else { 8.51 + if (! new File(outDir).isDirectory()) { 8.52 + print(outDir + " directory does not exist!"); 8.53 + exit(1); 8.54 + } 8.55 +} 8.56 + 8.57 +var Files = Java.type("java.nio.file.Files"); 8.58 +var FileSystems = Java.type("java.nio.file.FileSystems"); 8.59 +var Paths = Java.type("java.nio.file.Paths"); 8.60 + 8.61 +var zipfile = Paths.get(arguments[0]) 8.62 +var fs = FileSystems.newFileSystem(zipfile, null); 8.63 +var root = fs.rootDirectories[0]; 8.64 + 8.65 +// walk root and handle each Path 8.66 +Files.walk(root).forEach( 8.67 + function(p) { 8.68 + var outPath = outDir + 8.69 + p.toString().replace('/', File.separatorChar); 8.70 + print(outPath); 8.71 + if (Files.isDirectory(p)) { 8.72 + // create directories as needed 8.73 + new File(outPath).mkdirs(); 8.74 + } else { 8.75 + // copy a 'file' resource 8.76 + Files.copy(p, new File(outPath).toPath()); 8.77 + } 8.78 + } 8.79 +); 8.80 + 8.81 +// done 8.82 +fs.close();
9.1 --- a/src/jdk/nashorn/internal/codegen/AssignSymbols.java Thu May 28 20:55:21 2015 -0700 9.2 +++ b/src/jdk/nashorn/internal/codegen/AssignSymbols.java Wed Jun 03 20:30:20 2015 -0700 9.3 @@ -84,6 +84,7 @@ 9.4 import jdk.nashorn.internal.ir.VarNode; 9.5 import jdk.nashorn.internal.ir.WithNode; 9.6 import jdk.nashorn.internal.ir.visitor.NodeVisitor; 9.7 +import jdk.nashorn.internal.parser.TokenType; 9.8 import jdk.nashorn.internal.runtime.Context; 9.9 import jdk.nashorn.internal.runtime.ECMAErrors; 9.10 import jdk.nashorn.internal.runtime.ErrorManager; 9.11 @@ -714,12 +715,10 @@ 9.12 9.13 @Override 9.14 public Node leaveBinaryNode(final BinaryNode binaryNode) { 9.15 - switch (binaryNode.tokenType()) { 9.16 - case ASSIGN: 9.17 + if (binaryNode.isTokenType(TokenType.ASSIGN)) { 9.18 return leaveASSIGN(binaryNode); 9.19 - default: 9.20 - return super.leaveBinaryNode(binaryNode); 9.21 } 9.22 + return super.leaveBinaryNode(binaryNode); 9.23 } 9.24 9.25 private Node leaveASSIGN(final BinaryNode binaryNode) {
10.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java Thu May 28 20:55:21 2015 -0700 10.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java Wed Jun 03 20:30:20 2015 -0700 10.3 @@ -3798,7 +3798,6 @@ 10.4 emitBranch(binaryNode, onTrue, true); 10.5 if (isCurrentDiscard) { 10.6 method.label(onTrue); 10.7 - method.pop(); 10.8 } else { 10.9 method.load(false); 10.10 method._goto(skip);
11.1 --- a/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java Thu May 28 20:55:21 2015 -0700 11.2 +++ b/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java Wed Jun 03 20:30:20 2015 -0700 11.3 @@ -459,7 +459,7 @@ 11.4 // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first. 11.5 final Expression lhs = binaryNode.lhs(); 11.6 final LvarType lhsType; 11.7 - if (!(lhs instanceof IdentNode && binaryNode.tokenType() == TokenType.ASSIGN)) { 11.8 + if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) { 11.9 lhsType = visitExpression(lhs); 11.10 } else { 11.11 // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def.
12.1 --- a/src/jdk/nashorn/internal/codegen/Lower.java Thu May 28 20:55:21 2015 -0700 12.2 +++ b/src/jdk/nashorn/internal/codegen/Lower.java Wed Jun 03 20:30:20 2015 -0700 12.3 @@ -200,7 +200,7 @@ 12.4 final String name = getConstantPropertyName(indexNode.getIndex()); 12.5 if (name != null) { 12.6 // If index node is a constant property name convert index node to access node. 12.7 - assert Token.descType(indexNode.getToken()) == TokenType.LBRACKET; 12.8 + assert indexNode.isIndex(); 12.9 return new AccessNode(indexNode.getToken(), indexNode.getFinish(), indexNode.getBase(), name); 12.10 } 12.11 return super.leaveIndexNode(indexNode);
13.1 --- a/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java Thu May 28 20:55:21 2015 -0700 13.2 +++ b/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java Wed Jun 03 20:30:20 2015 -0700 13.3 @@ -61,7 +61,7 @@ 13.4 import jdk.nashorn.internal.runtime.options.Options; 13.5 13.6 /** 13.7 - * Static utility that encapsulates persistence of type information for functions compiled with optimistic 13.8 + * <p>Static utility that encapsulates persistence of type information for functions compiled with optimistic 13.9 * typing. With this feature enabled, when a JavaScript function is recompiled because it gets deoptimized, 13.10 * the type information for deoptimization is stored in a cache file. If the same function is compiled in a 13.11 * subsequent JVM invocation, the type information is used for initial compilation, thus allowing the system 13.12 @@ -77,6 +77,7 @@ 13.13 * {@code nashorn.typeInfo.cleanupDelaySeconds} system property. You can also specify the word 13.14 * {@code unlimited} as the value for {@code nashorn.typeInfo.maxFiles} in which case the type info cache is 13.15 * allowed to grow without limits. 13.16 + * </p> 13.17 */ 13.18 public final class OptimisticTypesPersistence { 13.19 // Default is 0, for disabling the feature when not specified. A reasonable default when enabled is
14.1 --- a/src/jdk/nashorn/internal/ir/AccessNode.java Thu May 28 20:55:21 2015 -0700 14.2 +++ b/src/jdk/nashorn/internal/ir/AccessNode.java Wed Jun 03 20:30:20 2015 -0700 14.3 @@ -28,8 +28,6 @@ 14.4 import jdk.nashorn.internal.codegen.types.Type; 14.5 import jdk.nashorn.internal.ir.annotations.Immutable; 14.6 import jdk.nashorn.internal.ir.visitor.NodeVisitor; 14.7 -import jdk.nashorn.internal.parser.Token; 14.8 -import jdk.nashorn.internal.parser.TokenType; 14.9 14.10 /** 14.11 * IR representation of a property access (period operator.) 14.12 @@ -103,14 +101,6 @@ 14.13 return property; 14.14 } 14.15 14.16 - /** 14.17 - * Return true if this node represents an index operation normally represented as {@link IndexNode}. 14.18 - * @return true if an index access. 14.19 - */ 14.20 - public boolean isIndex() { 14.21 - return Token.descType(getToken()) == TokenType.LBRACKET; 14.22 - } 14.23 - 14.24 private AccessNode setBase(final Expression base) { 14.25 if (this.base == base) { 14.26 return this;
15.1 --- a/src/jdk/nashorn/internal/ir/BaseNode.java Thu May 28 20:55:21 2015 -0700 15.2 +++ b/src/jdk/nashorn/internal/ir/BaseNode.java Wed Jun 03 20:30:20 2015 -0700 15.3 @@ -29,6 +29,7 @@ 15.4 15.5 import jdk.nashorn.internal.codegen.types.Type; 15.6 import jdk.nashorn.internal.ir.annotations.Immutable; 15.7 +import jdk.nashorn.internal.parser.TokenType; 15.8 15.9 /** 15.10 * IR base for accessing/indexing nodes. 15.11 @@ -122,6 +123,14 @@ 15.12 } 15.13 15.14 /** 15.15 + * Return true if this node represents an index operation normally represented as {@link IndexNode}. 15.16 + * @return true if an index access. 15.17 + */ 15.18 + public boolean isIndex() { 15.19 + return isTokenType(TokenType.LBRACKET); 15.20 + } 15.21 + 15.22 + /** 15.23 * Mark this node as being the callee operand of a {@link CallNode}. 15.24 * @return a base node identical to this one in all aspects except with its function flag set. 15.25 */
16.1 --- a/src/jdk/nashorn/internal/ir/BinaryNode.java Thu May 28 20:55:21 2015 -0700 16.2 +++ b/src/jdk/nashorn/internal/ir/BinaryNode.java Wed Jun 03 20:30:20 2015 -0700 16.3 @@ -312,7 +312,7 @@ 16.4 16.5 @Override 16.6 public boolean isSelfModifying() { 16.7 - return isAssignment() && tokenType() != TokenType.ASSIGN; 16.8 + return isAssignment() && !isTokenType(TokenType.ASSIGN); 16.9 } 16.10 16.11 @Override 16.12 @@ -529,7 +529,7 @@ 16.13 final TokenType tokenType = tokenType(); 16.14 if(tokenType == TokenType.ADD || tokenType == TokenType.ASSIGN_ADD) { 16.15 return OPTIMISTIC_UNDECIDED_TYPE; 16.16 - } else if (CAN_OVERFLOW.contains(tokenType())) { 16.17 + } else if (CAN_OVERFLOW.contains(tokenType)) { 16.18 return Type.INT; 16.19 } 16.20 return getMostPessimisticType();
17.1 --- a/src/jdk/nashorn/internal/ir/LexicalContext.java Thu May 28 20:55:21 2015 -0700 17.2 +++ b/src/jdk/nashorn/internal/ir/LexicalContext.java Wed Jun 03 20:30:20 2015 -0700 17.3 @@ -204,7 +204,7 @@ 17.4 /** 17.5 * Explicitly apply flags to the topmost element on the stack. This is only valid to use from a 17.6 * {@code NodeVisitor.leaveXxx()} method and only on the node being exited at the time. It is not mandatory to use, 17.7 - * as {@link #pop(LexicalContextNode)} will apply the flags automatically, but this method can be used to apply them 17.8 + * as {@link #pop(Node)} will apply the flags automatically, but this method can be used to apply them 17.9 * during the {@code leaveXxx()} method in case its logic depends on the value of the flags. 17.10 * @param node the node to apply the flags to. Must be the topmost node on the stack. 17.11 * @return the passed in node, or a modified node (if any flags were modified)
18.1 --- a/src/jdk/nashorn/internal/ir/Node.java Thu May 28 20:55:21 2015 -0700 18.2 +++ b/src/jdk/nashorn/internal/ir/Node.java Wed Jun 03 20:30:20 2015 -0700 18.3 @@ -220,26 +220,28 @@ 18.4 } 18.5 18.6 /** 18.7 - * Return token tokenType from a token descriptor. 18.8 + * Returns this node's token's type. If you want to check for the node having a specific token type, 18.9 + * consider using {@link #isTokenType(TokenType)} instead. 18.10 * 18.11 - * @return Type of token. 18.12 + * @return type of token. 18.13 */ 18.14 public TokenType tokenType() { 18.15 return Token.descType(token); 18.16 } 18.17 18.18 /** 18.19 - * Test token tokenType. 18.20 + * Tests if this node has the specific token type. 18.21 * 18.22 - * @param type a type to check this token against 18.23 + * @param type a token type to check this node's token type against 18.24 * @return true if token types match. 18.25 */ 18.26 public boolean isTokenType(final TokenType type) { 18.27 - return Token.descType(token) == type; 18.28 + return tokenType() == type; 18.29 } 18.30 18.31 /** 18.32 - * Get the token for this location 18.33 + * Get the token for this node. If you want to retrieve the token's type, consider using 18.34 + * {@link #tokenType()} or {@link #isTokenType(TokenType)} instead. 18.35 * @return the token 18.36 */ 18.37 public long getToken() {
19.1 --- a/src/jdk/nashorn/internal/ir/TryNode.java Thu May 28 20:55:21 2015 -0700 19.2 +++ b/src/jdk/nashorn/internal/ir/TryNode.java Wed Jun 03 20:30:20 2015 -0700 19.3 @@ -57,7 +57,7 @@ 19.4 * block was not terminal; the original jump/return is simply ignored if the finally block itself 19.5 * terminates). The reason for this somewhat strange arrangement is that we didn't want to create a 19.6 * separate class for the (label, BlockStatement pair) but rather reused the already available LabelNode. 19.7 - * However, if we simply used List<LabelNode> without wrapping the label nodes in an additional Block, 19.8 + * However, if we simply used List<LabelNode> without wrapping the label nodes in an additional Block, 19.9 * that would've thrown off visitors relying on BlockLexicalContext -- same reason why we never use 19.10 * Statement as the type of bodies of e.g. IfNode, WhileNode etc. but rather blockify them even when they're 19.11 * single statements.
20.1 --- a/src/jdk/nashorn/internal/ir/VarNode.java Thu May 28 20:55:21 2015 -0700 20.2 +++ b/src/jdk/nashorn/internal/ir/VarNode.java Wed Jun 03 20:30:20 2015 -0700 20.3 @@ -27,7 +27,6 @@ 20.4 20.5 import jdk.nashorn.internal.ir.annotations.Immutable; 20.6 import jdk.nashorn.internal.ir.visitor.NodeVisitor; 20.7 -import jdk.nashorn.internal.parser.Token; 20.8 20.9 /** 20.10 * Node represents a var/let declaration. 20.11 @@ -182,7 +181,7 @@ 20.12 20.13 @Override 20.14 public void toString(final StringBuilder sb, final boolean printType) { 20.15 - sb.append(Token.descType(getToken()).getName()).append(' '); 20.16 + sb.append(tokenType().getName()).append(' '); 20.17 name.toString(sb, printType); 20.18 20.19 if (init != null) {
21.1 --- a/src/jdk/nashorn/internal/objects/Global.java Thu May 28 20:55:21 2015 -0700 21.2 +++ b/src/jdk/nashorn/internal/objects/Global.java Wed Jun 03 20:30:20 2015 -0700 21.3 @@ -220,7 +220,12 @@ 21.4 @Property(name = "Number", attributes = Attribute.NOT_ENUMERABLE) 21.5 public volatile Object number; 21.6 21.7 - /** ECMA 15.1.4.7 Date constructor */ 21.8 + /** 21.9 + * Getter for ECMA 15.1.4.7 Date property 21.10 + * 21.11 + * @param self self reference 21.12 + * @return Date property value 21.13 + */ 21.14 @Getter(name = "Date", attributes = Attribute.NOT_ENUMERABLE) 21.15 public static Object getDate(final Object self) { 21.16 final Global global = Global.instanceFrom(self); 21.17 @@ -230,6 +235,12 @@ 21.18 return global.date; 21.19 } 21.20 21.21 + /** 21.22 + * Setter for ECMA 15.1.4.7 Date property 21.23 + * 21.24 + * @param self self reference 21.25 + * @param value value for the Date property 21.26 + */ 21.27 @Setter(name = "Date", attributes = Attribute.NOT_ENUMERABLE) 21.28 public static void setDate(final Object self, final Object value) { 21.29 final Global global = Global.instanceFrom(self); 21.30 @@ -238,7 +249,12 @@ 21.31 21.32 private volatile Object date = LAZY_SENTINEL; 21.33 21.34 - /** ECMA 15.1.4.8 RegExp constructor */ 21.35 + /** 21.36 + * Getter for ECMA 15.1.4.8 RegExp property 21.37 + * 21.38 + * @param self self reference 21.39 + * @return RegExp property value 21.40 + */ 21.41 @Getter(name = "RegExp", attributes = Attribute.NOT_ENUMERABLE) 21.42 public static Object getRegExp(final Object self) { 21.43 final Global global = Global.instanceFrom(self); 21.44 @@ -248,6 +264,12 @@ 21.45 return global.regexp; 21.46 } 21.47 21.48 + /** 21.49 + * Setter for ECMA 15.1.4.8 RegExp property 21.50 + * 21.51 + * @param self self reference 21.52 + * @param value value for the RegExp property 21.53 + */ 21.54 @Setter(name = "RegExp", attributes = Attribute.NOT_ENUMERABLE) 21.55 public static void setRegExp(final Object self, final Object value) { 21.56 final Global global = Global.instanceFrom(self); 21.57 @@ -256,7 +278,11 @@ 21.58 21.59 private volatile Object regexp = LAZY_SENTINEL; 21.60 21.61 - /** ECMA 15.12 - The JSON object */ 21.62 + /** 21.63 + * Getter for ECMA 15.12 - The JSON property 21.64 + * @param self self reference 21.65 + * @return the value of JSON property 21.66 + */ 21.67 @Getter(name = "JSON", attributes = Attribute.NOT_ENUMERABLE) 21.68 public static Object getJSON(final Object self) { 21.69 final Global global = Global.instanceFrom(self); 21.70 @@ -266,6 +292,11 @@ 21.71 return global.json; 21.72 } 21.73 21.74 + /** 21.75 + * Setter for ECMA 15.12 - The JSON property 21.76 + * @param self self reference 21.77 + * @param value value for the JSON property 21.78 + */ 21.79 @Setter(name = "JSON", attributes = Attribute.NOT_ENUMERABLE) 21.80 public static void setJSON(final Object self, final Object value) { 21.81 final Global global = Global.instanceFrom(self); 21.82 @@ -274,7 +305,11 @@ 21.83 21.84 private volatile Object json = LAZY_SENTINEL; 21.85 21.86 - /** Nashorn extension: global.JSAdapter */ 21.87 + /** 21.88 + * Getter for Nashorn extension: global.JSAdapter 21.89 + * @param self self reference 21.90 + * @return value of the JSAdapter property 21.91 + */ 21.92 @Getter(name = "JSAdapter", attributes = Attribute.NOT_ENUMERABLE) 21.93 public static Object getJSAdapter(final Object self) { 21.94 final Global global = Global.instanceFrom(self); 21.95 @@ -284,6 +319,11 @@ 21.96 return global.jsadapter; 21.97 } 21.98 21.99 + /** 21.100 + * Setter for Nashorn extension: global.JSAdapter 21.101 + * @param self self reference 21.102 + * @param value value for the JSAdapter property 21.103 + */ 21.104 @Setter(name = "JSAdapter", attributes = Attribute.NOT_ENUMERABLE) 21.105 public static void setJSAdapter(final Object self, final Object value) { 21.106 final Global global = Global.instanceFrom(self); 21.107 @@ -300,7 +340,11 @@ 21.108 @Property(name = "Error", attributes = Attribute.NOT_ENUMERABLE) 21.109 public volatile Object error; 21.110 21.111 - /** EvalError object */ 21.112 + /** 21.113 + * Getter for the EvalError property 21.114 + * @param self self reference 21.115 + * @return the value of EvalError property 21.116 + */ 21.117 @Getter(name = "EvalError", attributes = Attribute.NOT_ENUMERABLE) 21.118 public static Object getEvalError(final Object self) { 21.119 final Global global = Global.instanceFrom(self); 21.120 @@ -310,6 +354,11 @@ 21.121 return global.evalError; 21.122 } 21.123 21.124 + /** 21.125 + * Setter for the EvalError property 21.126 + * @param self self reference 21.127 + * @param value value of the EvalError property 21.128 + */ 21.129 @Setter(name = "EvalError", attributes = Attribute.NOT_ENUMERABLE) 21.130 public static void setEvalError(final Object self, final Object value) { 21.131 final Global global = Global.instanceFrom(self); 21.132 @@ -318,7 +367,11 @@ 21.133 21.134 private volatile Object evalError = LAZY_SENTINEL; 21.135 21.136 - /** RangeError object */ 21.137 + /** 21.138 + * Getter for the RangeError property. 21.139 + * @param self self reference 21.140 + * @return the value of RangeError property 21.141 + */ 21.142 @Getter(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE) 21.143 public static Object getRangeError(final Object self) { 21.144 final Global global = Global.instanceFrom(self); 21.145 @@ -328,6 +381,12 @@ 21.146 return global.rangeError; 21.147 } 21.148 21.149 + 21.150 + /** 21.151 + * Setter for the RangeError property. 21.152 + * @param self self reference 21.153 + * @param value value for the RangeError property 21.154 + */ 21.155 @Setter(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE) 21.156 public static void setRangeError(final Object self, final Object value) { 21.157 final Global global = Global.instanceFrom(self); 21.158 @@ -348,7 +407,11 @@ 21.159 @Property(name = "TypeError", attributes = Attribute.NOT_ENUMERABLE) 21.160 public volatile Object typeError; 21.161 21.162 - /** URIError object */ 21.163 + /** 21.164 + * Getter for the URIError property. 21.165 + * @param self self reference 21.166 + * @return the value of URIError property 21.167 + */ 21.168 @Getter(name = "URIError", attributes = Attribute.NOT_ENUMERABLE) 21.169 public static Object getURIError(final Object self) { 21.170 final Global global = Global.instanceFrom(self); 21.171 @@ -358,6 +421,11 @@ 21.172 return global.uriError; 21.173 } 21.174 21.175 + /** 21.176 + * Setter for the URIError property. 21.177 + * @param self self reference 21.178 + * @param value value for the URIError property 21.179 + */ 21.180 @Setter(name = "URIError", attributes = Attribute.NOT_ENUMERABLE) 21.181 public static void setURIError(final Object self, final Object value) { 21.182 final Global global = Global.instanceFrom(self); 21.183 @@ -366,7 +434,11 @@ 21.184 21.185 private volatile Object uriError = LAZY_SENTINEL; 21.186 21.187 - /** ArrayBuffer object */ 21.188 + /** 21.189 + * Getter for the ArrayBuffer property. 21.190 + * @param self self reference 21.191 + * @return the value of the ArrayBuffer property 21.192 + */ 21.193 @Getter(name = "ArrayBuffer", attributes = Attribute.NOT_ENUMERABLE) 21.194 public static Object getArrayBuffer(final Object self) { 21.195 final Global global = Global.instanceFrom(self); 21.196 @@ -376,6 +448,11 @@ 21.197 return global.arrayBuffer; 21.198 } 21.199 21.200 + /** 21.201 + * Setter for the ArrayBuffer property. 21.202 + * @param self self reference 21.203 + * @param value value of the ArrayBuffer property 21.204 + */ 21.205 @Setter(name = "ArrayBuffer", attributes = Attribute.NOT_ENUMERABLE) 21.206 public static void setArrayBuffer(final Object self, final Object value) { 21.207 final Global global = Global.instanceFrom(self); 21.208 @@ -384,7 +461,11 @@ 21.209 21.210 private volatile Object arrayBuffer; 21.211 21.212 - /** DataView object */ 21.213 + /** 21.214 + * Getter for the DataView property. 21.215 + * @param self self reference 21.216 + * @return the value of the DataView property 21.217 + */ 21.218 @Getter(name = "DataView", attributes = Attribute.NOT_ENUMERABLE) 21.219 public static Object getDataView(final Object self) { 21.220 final Global global = Global.instanceFrom(self); 21.221 @@ -394,6 +475,12 @@ 21.222 return global.dataView; 21.223 } 21.224 21.225 + 21.226 + /** 21.227 + * Setter for the DataView property. 21.228 + * @param self self reference 21.229 + * @param value value of the DataView property 21.230 + */ 21.231 @Setter(name = "DataView", attributes = Attribute.NOT_ENUMERABLE) 21.232 public static void setDataView(final Object self, final Object value) { 21.233 final Global global = Global.instanceFrom(self); 21.234 @@ -402,7 +489,11 @@ 21.235 21.236 private volatile Object dataView; 21.237 21.238 - /** TypedArray (int8) */ 21.239 + /** 21.240 + * Getter for the Int8Array property. 21.241 + * @param self self reference 21.242 + * @return the value of the Int8Array property. 21.243 + */ 21.244 @Getter(name = "Int8Array", attributes = Attribute.NOT_ENUMERABLE) 21.245 public static Object getInt8Array(final Object self) { 21.246 final Global global = Global.instanceFrom(self); 21.247 @@ -412,6 +503,11 @@ 21.248 return global.int8Array; 21.249 } 21.250 21.251 + /** 21.252 + * Setter for the Int8Array property. 21.253 + * @param self self reference 21.254 + * @param value value of the Int8Array property 21.255 + */ 21.256 @Setter(name = "Int8Array", attributes = Attribute.NOT_ENUMERABLE) 21.257 public static void setInt8Array(final Object self, final Object value) { 21.258 final Global global = Global.instanceFrom(self); 21.259 @@ -420,7 +516,11 @@ 21.260 21.261 private volatile Object int8Array; 21.262 21.263 - /** TypedArray (uint8) */ 21.264 + /** 21.265 + * Getter for the Uin8Array property. 21.266 + * @param self self reference 21.267 + * @return the value of the Uint8Array property 21.268 + */ 21.269 @Getter(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE) 21.270 public static Object getUint8Array(final Object self) { 21.271 final Global global = Global.instanceFrom(self); 21.272 @@ -430,6 +530,11 @@ 21.273 return global.uint8Array; 21.274 } 21.275 21.276 + /** 21.277 + * Setter for the Uin8Array property. 21.278 + * @param self self reference 21.279 + * @param value value of the Uin8Array property 21.280 + */ 21.281 @Setter(name = "Uint8Array", attributes = Attribute.NOT_ENUMERABLE) 21.282 public static void setUint8Array(final Object self, final Object value) { 21.283 final Global global = Global.instanceFrom(self); 21.284 @@ -438,7 +543,11 @@ 21.285 21.286 private volatile Object uint8Array; 21.287 21.288 - /** TypedArray (uint8) - Clamped */ 21.289 + /** 21.290 + * Getter for the Uint8ClampedArray property. 21.291 + * @param self self reference 21.292 + * @return the value of the Uint8ClampedArray property 21.293 + */ 21.294 @Getter(name = "Uint8ClampedArray", attributes = Attribute.NOT_ENUMERABLE) 21.295 public static Object getUint8ClampedArray(final Object self) { 21.296 final Global global = Global.instanceFrom(self); 21.297 @@ -448,6 +557,11 @@ 21.298 return global.uint8ClampedArray; 21.299 } 21.300 21.301 + /** 21.302 + * Setter for the Uint8ClampedArray property. 21.303 + * @param self self reference 21.304 + * @param value value of the Uint8ClampedArray property 21.305 + */ 21.306 @Setter(name = "Uint8ClampedArray", attributes = Attribute.NOT_ENUMERABLE) 21.307 public static void setUint8ClampedArray(final Object self, final Object value) { 21.308 final Global global = Global.instanceFrom(self); 21.309 @@ -456,7 +570,11 @@ 21.310 21.311 private volatile Object uint8ClampedArray; 21.312 21.313 - /** TypedArray (int16) */ 21.314 + /** 21.315 + * Getter for the Int16Array property. 21.316 + * @param self self reference 21.317 + * @return the value of the Int16Array property 21.318 + */ 21.319 @Getter(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE) 21.320 public static Object getInt16Array(final Object self) { 21.321 final Global global = Global.instanceFrom(self); 21.322 @@ -466,6 +584,11 @@ 21.323 return global.int16Array; 21.324 } 21.325 21.326 + /** 21.327 + * Setter for the Int16Array property. 21.328 + * @param self self reference 21.329 + * @param value value of the Int16Array property 21.330 + */ 21.331 @Setter(name = "Int16Array", attributes = Attribute.NOT_ENUMERABLE) 21.332 public static void setInt16Array(final Object self, final Object value) { 21.333 final Global global = Global.instanceFrom(self); 21.334 @@ -474,7 +597,11 @@ 21.335 21.336 private volatile Object int16Array; 21.337 21.338 - /** TypedArray (uint16) */ 21.339 + /** 21.340 + * Getter for the Uint16Array property. 21.341 + * @param self self reference 21.342 + * @return the value of the Uint16Array property 21.343 + */ 21.344 @Getter(name = "Uint16Array", attributes = Attribute.NOT_ENUMERABLE) 21.345 public static Object getUint16Array(final Object self) { 21.346 final Global global = Global.instanceFrom(self); 21.347 @@ -484,6 +611,11 @@ 21.348 return global.uint16Array; 21.349 } 21.350 21.351 + /** 21.352 + * Setter for the Uint16Array property. 21.353 + * @param self self reference 21.354 + * @param value value of the Uint16Array property 21.355 + */ 21.356 @Setter(name = "Uint16Array", attributes = Attribute.NOT_ENUMERABLE) 21.357 public static void setUint16Array(final Object self, final Object value) { 21.358 final Global global = Global.instanceFrom(self); 21.359 @@ -492,7 +624,12 @@ 21.360 21.361 private volatile Object uint16Array; 21.362 21.363 - /** TypedArray (int32) */ 21.364 + /** 21.365 + * Getter for the Int32Array property. 21.366 + * 21.367 + * @param self self reference 21.368 + * @return the value of the Int32Array property 21.369 + */ 21.370 @Getter(name = "Int32Array", attributes = Attribute.NOT_ENUMERABLE) 21.371 public static Object getInt32Array(final Object self) { 21.372 final Global global = Global.instanceFrom(self); 21.373 @@ -502,6 +639,13 @@ 21.374 return global.int32Array; 21.375 } 21.376 21.377 + 21.378 + /** 21.379 + * Setter for the Int32Array property. 21.380 + * 21.381 + * @param self self reference 21.382 + * @param value value of the Int32Array property 21.383 + */ 21.384 @Setter(name = "Int32Array", attributes = Attribute.NOT_ENUMERABLE) 21.385 public static void setInt32Array(final Object self, final Object value) { 21.386 final Global global = Global.instanceFrom(self); 21.387 @@ -510,7 +654,12 @@ 21.388 21.389 private volatile Object int32Array; 21.390 21.391 - /** TypedArray (uint32) */ 21.392 + /** 21.393 + * Getter of the Uint32Array property. 21.394 + * 21.395 + * @param self self reference 21.396 + * @return the value of the Uint32Array property 21.397 + */ 21.398 @Getter(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE) 21.399 public static Object getUint32Array(final Object self) { 21.400 final Global global = Global.instanceFrom(self); 21.401 @@ -520,6 +669,13 @@ 21.402 return global.uint32Array; 21.403 } 21.404 21.405 + 21.406 + /** 21.407 + * Setter of the Uint32Array property. 21.408 + * 21.409 + * @param self self reference 21.410 + * @param value value of the Uint32Array property 21.411 + */ 21.412 @Setter(name = "Uint32Array", attributes = Attribute.NOT_ENUMERABLE) 21.413 public static void setUint32Array(final Object self, final Object value) { 21.414 final Global global = Global.instanceFrom(self); 21.415 @@ -528,7 +684,12 @@ 21.416 21.417 private volatile Object uint32Array; 21.418 21.419 - /** TypedArray (float32) */ 21.420 + /** 21.421 + * Getter for the Float32Array property. 21.422 + * 21.423 + * @param self self reference 21.424 + * @return the value of the Float32Array property 21.425 + */ 21.426 @Getter(name = "Float32Array", attributes = Attribute.NOT_ENUMERABLE) 21.427 public static Object getFloat32Array(final Object self) { 21.428 final Global global = Global.instanceFrom(self); 21.429 @@ -538,6 +699,12 @@ 21.430 return global.float32Array; 21.431 } 21.432 21.433 + /** 21.434 + * Setter for the Float32Array property. 21.435 + * 21.436 + * @param self self reference 21.437 + * @param value value of the Float32Array property 21.438 + */ 21.439 @Setter(name = "Float32Array", attributes = Attribute.NOT_ENUMERABLE) 21.440 public static void setFloat32Array(final Object self, final Object value) { 21.441 final Global global = Global.instanceFrom(self); 21.442 @@ -546,7 +713,12 @@ 21.443 21.444 private volatile Object float32Array; 21.445 21.446 - /** TypedArray (float64) */ 21.447 + /** 21.448 + * Getter for the Float64Array property. 21.449 + * 21.450 + * @param self self reference 21.451 + * @return the value of the Float64Array property 21.452 + */ 21.453 @Getter(name = "Float64Array", attributes = Attribute.NOT_ENUMERABLE) 21.454 public static Object getFloat64Array(final Object self) { 21.455 final Global global = Global.instanceFrom(self); 21.456 @@ -556,6 +728,12 @@ 21.457 return global.float64Array; 21.458 } 21.459 21.460 + /** 21.461 + * Setter for the Float64Array property. 21.462 + * 21.463 + * @param self self reference 21.464 + * @param value value of the Float64Array property 21.465 + */ 21.466 @Setter(name = "Float64Array", attributes = Attribute.NOT_ENUMERABLE) 21.467 public static void setFloat64Array(final Object self, final Object value) { 21.468 final Global global = Global.instanceFrom(self); 21.469 @@ -592,7 +770,12 @@ 21.470 @Property(attributes = Attribute.NOT_ENUMERABLE) 21.471 public volatile Object org; 21.472 21.473 - /** Nashorn extension: Java access - global.javaImporter */ 21.474 + /** 21.475 + * Getter for the Nashorn extension: Java access - global.javaImporter. 21.476 + * 21.477 + * @param self self reference 21.478 + * @return the value of the JavaImporter property 21.479 + */ 21.480 @Getter(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE) 21.481 public static Object getJavaImporter(final Object self) { 21.482 final Global global = Global.instanceFrom(self); 21.483 @@ -602,6 +785,12 @@ 21.484 return global.javaImporter; 21.485 } 21.486 21.487 + /** 21.488 + * Setter for the Nashorn extension: Java access - global.javaImporter. 21.489 + * 21.490 + * @param self self reference 21.491 + * @param value value of the JavaImporter property 21.492 + */ 21.493 @Setter(name = "JavaImporter", attributes = Attribute.NOT_ENUMERABLE) 21.494 public static void setJavaImporter(final Object self, final Object value) { 21.495 final Global global = Global.instanceFrom(self); 21.496 @@ -610,7 +799,12 @@ 21.497 21.498 private volatile Object javaImporter; 21.499 21.500 - /** Nashorn extension: global.Java Object constructor. */ 21.501 + /** 21.502 + * Getter for the Nashorn extension: global.Java property. 21.503 + * 21.504 + * @param self self reference 21.505 + * @return the value of the Java property 21.506 + */ 21.507 @Getter(name = "Java", attributes = Attribute.NOT_ENUMERABLE) 21.508 public static Object getJavaApi(final Object self) { 21.509 final Global global = Global.instanceFrom(self); 21.510 @@ -620,6 +814,12 @@ 21.511 return global.javaApi; 21.512 } 21.513 21.514 + /** 21.515 + * Setter for the Nashorn extension: global.Java property. 21.516 + * 21.517 + * @param self self reference 21.518 + * @param value value of the Java property 21.519 + */ 21.520 @Setter(name = "Java", attributes = Attribute.NOT_ENUMERABLE) 21.521 public static void setJavaApi(final Object self, final Object value) { 21.522 final Global global = Global.instanceFrom(self); 21.523 @@ -2140,13 +2340,13 @@ 21.524 @Override 21.525 public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) { 21.526 PropertyMap ownMap = getMap(); 21.527 - LexicalScope lexicalScope = null; 21.528 + LexicalScope lexScope = null; 21.529 PropertyMap lexicalMap = null; 21.530 boolean hasLexicalDefinitions = false; 21.531 21.532 if (context.getEnv()._es6) { 21.533 - lexicalScope = (LexicalScope) getLexicalScope(); 21.534 - lexicalMap = lexicalScope.getMap(); 21.535 + lexScope = (LexicalScope) getLexicalScope(); 21.536 + lexicalMap = lexScope.getMap(); 21.537 21.538 for (final jdk.nashorn.internal.runtime.Property property : properties) { 21.539 if (property.isLexicalBinding()) { 21.540 @@ -2166,8 +2366,8 @@ 21.541 21.542 for (final jdk.nashorn.internal.runtime.Property property : properties) { 21.543 if (property.isLexicalBinding()) { 21.544 - assert lexicalScope != null; 21.545 - lexicalMap = lexicalScope.addBoundProperty(lexicalMap, source, property); 21.546 + assert lexScope != null; 21.547 + lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property); 21.548 21.549 if (ownMap.findProperty(property.getKey()) != null) { 21.550 // If property exists in the global object invalidate any global constant call sites. 21.551 @@ -2181,7 +2381,8 @@ 21.552 setMap(ownMap); 21.553 21.554 if (hasLexicalDefinitions) { 21.555 - lexicalScope.setMap(lexicalMap); 21.556 + assert lexScope != null; 21.557 + lexScope.setMap(lexicalMap); 21.558 invalidateLexicalSwitchPoint(); 21.559 } 21.560 }
22.1 --- a/src/jdk/nashorn/internal/objects/NativeJava.java Thu May 28 20:55:21 2015 -0700 22.2 +++ b/src/jdk/nashorn/internal/objects/NativeJava.java Wed Jun 03 20:30:20 2015 -0700 22.3 @@ -33,10 +33,10 @@ 22.4 import java.util.Collection; 22.5 import java.util.Deque; 22.6 import java.util.List; 22.7 +import java.util.Queue; 22.8 import jdk.internal.dynalink.beans.StaticClass; 22.9 import jdk.internal.dynalink.support.TypeUtilities; 22.10 import jdk.nashorn.api.scripting.JSObject; 22.11 -import jdk.nashorn.api.scripting.ScriptUtils; 22.12 import jdk.nashorn.internal.objects.annotations.Attribute; 22.13 import jdk.nashorn.internal.objects.annotations.Function; 22.14 import jdk.nashorn.internal.objects.annotations.ScriptClass; 22.15 @@ -339,7 +339,8 @@ 22.16 22.17 /** 22.18 * Given a script object and a Java type, converts the script object into the desired Java type. Currently it 22.19 - * performs shallow creation of Java arrays, as well as wrapping of objects in Lists and Dequeues. Example: 22.20 + * performs shallow creation of Java arrays, as well as wrapping of objects in Lists, Dequeues, Queues, 22.21 + * and Collections. Example: 22.22 * <pre> 22.23 * var anArray = [1, "13", false] 22.24 * var javaIntArray = Java.to(anArray, "int[]") 22.25 @@ -353,9 +354,10 @@ 22.26 * object to create. Can not be null. If undefined, a "default" conversion is presumed (allowing the argument to be 22.27 * omitted). 22.28 * @return a Java object whose value corresponds to the original script object's value. Specifically, for array 22.29 - * target types, returns a Java array of the same type with contents converted to the array's component type. Does 22.30 - * not recursively convert for multidimensional arrays. For {@link List} or {@link Deque}, returns a live wrapper 22.31 - * around the object, see {@link ListAdapter} for details. Returns null if obj is null. 22.32 + * target types, returns a Java array of the same type with contents converted to the array's component type. 22.33 + * Converts recursively when the target type is multidimensional array. For {@link List}, {@link Deque}, 22.34 + * {@link Queue}, or {@link Collection}, returns a live wrapper around the object, see {@link ListAdapter} for 22.35 + * details. Returns null if obj is null. 22.36 * @throws ClassNotFoundException if the class described by objType is not found 22.37 */ 22.38 @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) 22.39 @@ -385,7 +387,7 @@ 22.40 return JSType.toJavaArray(obj, targetClass.getComponentType()); 22.41 } 22.42 22.43 - if(targetClass == List.class || targetClass == Deque.class) { 22.44 + if (targetClass == List.class || targetClass == Deque.class || targetClass == Queue.class || targetClass == Collection.class) { 22.45 return ListAdapter.create(obj); 22.46 } 22.47
23.1 --- a/src/jdk/nashorn/internal/objects/NativeObject.java Thu May 28 20:55:21 2015 -0700 23.2 +++ b/src/jdk/nashorn/internal/objects/NativeObject.java Wed Jun 03 20:30:20 2015 -0700 23.3 @@ -765,7 +765,7 @@ 23.4 continue; 23.5 } 23.6 properties.add(AccessorProperty.create(methodName, Property.NOT_WRITABLE, getBoundBeanMethodGetter(source, 23.7 - method), null)); 23.8 + method), Lookup.EMPTY_SETTER)); 23.9 } 23.10 for(final String propertyName: propertyNames) { 23.11 MethodHandle getter;
24.1 --- a/src/jdk/nashorn/internal/parser/Parser.java Thu May 28 20:55:21 2015 -0700 24.2 +++ b/src/jdk/nashorn/internal/parser/Parser.java Wed Jun 03 20:30:20 2015 -0700 24.3 @@ -607,7 +607,7 @@ 24.4 * @return whether the ident can be used as L-value 24.5 */ 24.6 private static boolean checkIdentLValue(final IdentNode ident) { 24.7 - return Token.descType(ident.getToken()).getKind() != TokenKind.KEYWORD; 24.8 + return ident.tokenType().getKind() != TokenKind.KEYWORD; 24.9 } 24.10 24.11 /**
25.1 --- a/src/jdk/nashorn/internal/runtime/CodeInstaller.java Thu May 28 20:55:21 2015 -0700 25.2 +++ b/src/jdk/nashorn/internal/runtime/CodeInstaller.java Wed Jun 03 20:30:20 2015 -0700 25.3 @@ -86,7 +86,7 @@ 25.4 * @param source the script source 25.5 * @param mainClassName the main class name 25.6 * @param classBytes map of class names to class bytes 25.7 - * @param initializers compilation id -> FunctionInitializer map 25.8 + * @param initializers compilation id -> FunctionInitializer map 25.9 * @param constants constants array 25.10 * @param compilationId compilation id 25.11 */
26.1 --- a/src/jdk/nashorn/internal/runtime/JSObjectListAdapter.java Thu May 28 20:55:21 2015 -0700 26.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 26.3 @@ -1,56 +0,0 @@ 26.4 -/* 26.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 26.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.7 - * 26.8 - * This code is free software; you can redistribute it and/or modify it 26.9 - * under the terms of the GNU General Public License version 2 only, as 26.10 - * published by the Free Software Foundation. Oracle designates this 26.11 - * particular file as subject to the "Classpath" exception as provided 26.12 - * by Oracle in the LICENSE file that accompanied this code. 26.13 - * 26.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 26.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 26.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26.17 - * version 2 for more details (a copy is included in the LICENSE file that 26.18 - * accompanied this code). 26.19 - * 26.20 - * You should have received a copy of the GNU General Public License version 26.21 - * 2 along with this work; if not, write to the Free Software Foundation, 26.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26.23 - * 26.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 26.25 - * or visit www.oracle.com if you need additional information or have any 26.26 - * questions. 26.27 - */ 26.28 - 26.29 -package jdk.nashorn.internal.runtime; 26.30 - 26.31 -import jdk.nashorn.api.scripting.JSObject; 26.32 - 26.33 -/** 26.34 - * A ListAdapter that can wraps a JSObject. 26.35 - */ 26.36 -public final class JSObjectListAdapter extends ListAdapter { 26.37 - /** 26.38 - * Creates a new list wrapper for the specified JSObject. 26.39 - * @param obj JSOcript the object to wrap 26.40 - */ 26.41 - public JSObjectListAdapter(final JSObject obj) { 26.42 - super(obj); 26.43 - } 26.44 - 26.45 - @Override 26.46 - public int size() { 26.47 - return JSType.toInt32(((JSObject)obj).getMember("length")); 26.48 - } 26.49 - 26.50 - @Override 26.51 - protected Object getAt(final int index) { 26.52 - return ((JSObject)obj).getSlot(index); 26.53 - } 26.54 - 26.55 - @Override 26.56 - protected void setAt(final int index, final Object element) { 26.57 - ((JSObject)obj).setSlot(index, element); 26.58 - } 26.59 -}
27.1 --- a/src/jdk/nashorn/internal/runtime/JSType.java Thu May 28 20:55:21 2015 -0700 27.2 +++ b/src/jdk/nashorn/internal/runtime/JSType.java Wed Jun 03 20:30:20 2015 -0700 27.3 @@ -34,7 +34,6 @@ 27.4 import java.lang.reflect.Array; 27.5 import java.util.Arrays; 27.6 import java.util.Collections; 27.7 -import java.util.Deque; 27.8 import java.util.List; 27.9 import jdk.internal.dynalink.beans.StaticClass; 27.10 import jdk.nashorn.api.scripting.AbstractJSObject; 27.11 @@ -181,10 +180,10 @@ 27.12 /** Div exact wrapper for potentially integer division that turns into float point */ 27.13 public static final Call DIV_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "divExact", long.class, long.class, long.class, int.class); 27.14 27.15 - /** Div zero wrapper for long division that handles (0/0) >>> 0 == 0 */ 27.16 + /** Div zero wrapper for long division that handles (0/0) >>> 0 == 0 */ 27.17 public static final Call DIV_ZERO_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "divZero", long.class, long.class, long.class); 27.18 27.19 - /** Mod zero wrapper for long division that handles (0%0) >>> 0 == 0 */ 27.20 + /** Mod zero wrapper for long division that handles (0%0) >>> 0 == 0 */ 27.21 public static final Call REM_ZERO_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "remZero", long.class, long.class, long.class); 27.22 27.23 /** Mod exact wrapper for potentially integer remainders that turns into float point */ 27.24 @@ -202,12 +201,6 @@ 27.25 /** Method handle to convert a JS Object to a Java array. */ 27.26 public static final Call TO_JAVA_ARRAY = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaArray", Object.class, Object.class, Class.class); 27.27 27.28 - /** Method handle to convert a JS Object to a Java List. */ 27.29 - public static final Call TO_JAVA_LIST = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaList", List.class, Object.class); 27.30 - 27.31 - /** Method handle to convert a JS Object to a Java deque. */ 27.32 - public static final Call TO_JAVA_DEQUE = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaDeque", Deque.class, Object.class); 27.33 - 27.34 /** Method handle for void returns. */ 27.35 public static final Call VOID_RETURN = staticCall(JSTYPE_LOOKUP, JSType.class, "voidReturn", void.class); 27.36 27.37 @@ -1352,24 +1345,6 @@ 27.38 } 27.39 27.40 /** 27.41 - * Converts a JavaScript object to a Java List. See {@link ListAdapter} for details. 27.42 - * @param obj the object to convert. Can be any array-like object. 27.43 - * @return a List that is live-backed by the JavaScript object. 27.44 - */ 27.45 - public static List<?> toJavaList(final Object obj) { 27.46 - return ListAdapter.create(obj); 27.47 - } 27.48 - 27.49 - /** 27.50 - * Converts a JavaScript object to a Java Deque. See {@link ListAdapter} for details. 27.51 - * @param obj the object to convert. Can be any array-like object. 27.52 - * @return a Deque that is live-backed by the JavaScript object. 27.53 - */ 27.54 - public static Deque<?> toJavaDeque(final Object obj) { 27.55 - return ListAdapter.create(obj); 27.56 - } 27.57 - 27.58 - /** 27.59 * Check if an object is null or undefined 27.60 * 27.61 * @param obj object to check
28.1 --- a/src/jdk/nashorn/internal/runtime/ListAdapter.java Thu May 28 20:55:21 2015 -0700 28.2 +++ b/src/jdk/nashorn/internal/runtime/ListAdapter.java Wed Jun 03 20:30:20 2015 -0700 28.3 @@ -25,17 +25,18 @@ 28.4 28.5 package jdk.nashorn.internal.runtime; 28.6 28.7 +import java.lang.invoke.MethodHandle; 28.8 import java.util.AbstractList; 28.9 import java.util.Deque; 28.10 import java.util.Iterator; 28.11 import java.util.ListIterator; 28.12 import java.util.NoSuchElementException; 28.13 +import java.util.Objects; 28.14 import java.util.RandomAccess; 28.15 import java.util.concurrent.Callable; 28.16 import jdk.nashorn.api.scripting.JSObject; 28.17 import jdk.nashorn.api.scripting.ScriptObjectMirror; 28.18 import jdk.nashorn.internal.runtime.linker.Bootstrap; 28.19 -import jdk.nashorn.internal.runtime.linker.InvokeByName; 28.20 28.21 /** 28.22 * An adapter that can wrap any ECMAScript Array-like object (that adheres to the array rules for the property 28.23 @@ -50,81 +51,56 @@ 28.24 * operations respectively, while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and 28.25 * {@code pop}. 28.26 */ 28.27 -public abstract class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> { 28.28 - // These add to the back and front of the list 28.29 - private static final Object PUSH = new Object(); 28.30 - private static InvokeByName getPUSH() { 28.31 - return Context.getGlobal().getInvokeByName(PUSH, 28.32 - new Callable<InvokeByName>() { 28.33 - @Override 28.34 - public InvokeByName call() { 28.35 - return new InvokeByName("push", Object.class, void.class, Object.class); 28.36 - } 28.37 - }); 28.38 +public final class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> { 28.39 + // Invoker creator for methods that add to the start or end of the list: PUSH and UNSHIFT. Takes fn, this, and value, returns void. 28.40 + private static final Callable<MethodHandle> ADD_INVOKER_CREATOR = invokerCreator(void.class, Object.class, JSObject.class, Object.class); 28.41 + 28.42 + // PUSH adds to the end of the list 28.43 + private static final Object PUSH = new Object(); 28.44 + private static MethodHandle getPushInvoker() { 28.45 + return getDynamicInvoker(PUSH, ADD_INVOKER_CREATOR); 28.46 } 28.47 28.48 + // UNSHIFT adds to the start of the list 28.49 private static final Object UNSHIFT = new Object(); 28.50 - private static InvokeByName getUNSHIFT() { 28.51 - return Context.getGlobal().getInvokeByName(UNSHIFT, 28.52 - new Callable<InvokeByName>() { 28.53 - @Override 28.54 - public InvokeByName call() { 28.55 - return new InvokeByName("unshift", Object.class, void.class, Object.class); 28.56 - } 28.57 - }); 28.58 + private static MethodHandle getUnshiftInvoker() { 28.59 + return getDynamicInvoker(UNSHIFT, ADD_INVOKER_CREATOR); 28.60 } 28.61 28.62 - // These remove from the back and front of the list 28.63 + // Invoker creator for methods that remove from the tail or head of the list: POP and SHIFT. Takes fn, this, returns Object. 28.64 + private static final Callable<MethodHandle> REMOVE_INVOKER_CREATOR = invokerCreator(Object.class, Object.class, JSObject.class); 28.65 + 28.66 + // POP removes from the to the end of the list 28.67 private static final Object POP = new Object(); 28.68 - private static InvokeByName getPOP() { 28.69 - return Context.getGlobal().getInvokeByName(POP, 28.70 - new Callable<InvokeByName>() { 28.71 - @Override 28.72 - public InvokeByName call() { 28.73 - return new InvokeByName("pop", Object.class, Object.class); 28.74 - } 28.75 - }); 28.76 + private static MethodHandle getPopInvoker() { 28.77 + return getDynamicInvoker(POP, REMOVE_INVOKER_CREATOR); 28.78 } 28.79 28.80 + // SHIFT removes from the to the start of the list 28.81 private static final Object SHIFT = new Object(); 28.82 - private static InvokeByName getSHIFT() { 28.83 - return Context.getGlobal().getInvokeByName(SHIFT, 28.84 - new Callable<InvokeByName>() { 28.85 - @Override 28.86 - public InvokeByName call() { 28.87 - return new InvokeByName("shift", Object.class, Object.class); 28.88 - } 28.89 - }); 28.90 + private static MethodHandle getShiftInvoker() { 28.91 + return getDynamicInvoker(SHIFT, REMOVE_INVOKER_CREATOR); 28.92 } 28.93 28.94 - // These insert and remove in the middle of the list 28.95 + // SPLICE can be used to add a value in the middle of the list. 28.96 private static final Object SPLICE_ADD = new Object(); 28.97 - private static InvokeByName getSPLICE_ADD() { 28.98 - return Context.getGlobal().getInvokeByName(SPLICE_ADD, 28.99 - new Callable<InvokeByName>() { 28.100 - @Override 28.101 - public InvokeByName call() { 28.102 - return new InvokeByName("splice", Object.class, void.class, int.class, int.class, Object.class); 28.103 - } 28.104 - }); 28.105 + private static final Callable<MethodHandle> SPLICE_ADD_INVOKER_CREATOR = invokerCreator(void.class, Object.class, JSObject.class, int.class, int.class, Object.class); 28.106 + private static MethodHandle getSpliceAddInvoker() { 28.107 + return getDynamicInvoker(SPLICE_ADD, SPLICE_ADD_INVOKER_CREATOR); 28.108 } 28.109 28.110 + // SPLICE can also be used to remove values from the middle of the list. 28.111 private static final Object SPLICE_REMOVE = new Object(); 28.112 - private static InvokeByName getSPLICE_REMOVE() { 28.113 - return Context.getGlobal().getInvokeByName(SPLICE_REMOVE, 28.114 - new Callable<InvokeByName>() { 28.115 - @Override 28.116 - public InvokeByName call() { 28.117 - return new InvokeByName("splice", Object.class, void.class, int.class, int.class); 28.118 - } 28.119 - }); 28.120 + private static final Callable<MethodHandle> SPLICE_REMOVE_INVOKER_CREATOR = invokerCreator(void.class, Object.class, JSObject.class, int.class, int.class); 28.121 + private static MethodHandle getSpliceRemoveInvoker() { 28.122 + return getDynamicInvoker(SPLICE_REMOVE, SPLICE_REMOVE_INVOKER_CREATOR); 28.123 } 28.124 28.125 /** wrapped object */ 28.126 - protected final Object obj; 28.127 + protected final JSObject obj; 28.128 28.129 // allow subclasses only in this package 28.130 - ListAdapter(final Object obj) { 28.131 + ListAdapter(final JSObject obj) { 28.132 this.obj = obj; 28.133 } 28.134 28.135 @@ -135,14 +111,16 @@ 28.136 * @return A ListAdapter wrapper object 28.137 */ 28.138 public static ListAdapter create(final Object obj) { 28.139 + return new ListAdapter(getJSObject(obj)); 28.140 + } 28.141 + 28.142 + private static JSObject getJSObject(final Object obj) { 28.143 if (obj instanceof ScriptObject) { 28.144 - final Object mirror = ScriptObjectMirror.wrap(obj, Context.getGlobal()); 28.145 - return new JSObjectListAdapter((JSObject)mirror); 28.146 + return (JSObject)ScriptObjectMirror.wrap(obj, Context.getGlobal()); 28.147 } else if (obj instanceof JSObject) { 28.148 - return new JSObjectListAdapter((JSObject)obj); 28.149 - } else { 28.150 - throw new IllegalArgumentException("ScriptObject or JSObject expected"); 28.151 + return (JSObject)obj; 28.152 } 28.153 + throw new IllegalArgumentException("ScriptObject or JSObject expected"); 28.154 } 28.155 28.156 @Override 28.157 @@ -151,28 +129,18 @@ 28.158 return getAt(index); 28.159 } 28.160 28.161 - /** 28.162 - * Get object at an index 28.163 - * @param index index in list 28.164 - * @return object 28.165 - */ 28.166 - protected abstract Object getAt(final int index); 28.167 + private Object getAt(final int index) { 28.168 + return obj.getSlot(index); 28.169 + } 28.170 28.171 @Override 28.172 public Object set(final int index, final Object element) { 28.173 checkRange(index); 28.174 final Object prevValue = getAt(index); 28.175 - setAt(index, element); 28.176 + obj.setSlot(index, element); 28.177 return prevValue; 28.178 } 28.179 28.180 - /** 28.181 - * Set object at an index 28.182 - * @param index index in list 28.183 - * @param element element 28.184 - */ 28.185 - protected abstract void setAt(final int index, final Object element); 28.186 - 28.187 private void checkRange(final int index) { 28.188 if(index < 0 || index >= size()) { 28.189 throw invalidIndex(index); 28.190 @@ -180,6 +148,11 @@ 28.191 } 28.192 28.193 @Override 28.194 + public int size() { 28.195 + return JSType.toInt32(obj.getMember("length")); 28.196 + } 28.197 + 28.198 + @Override 28.199 public final void push(final Object e) { 28.200 addFirst(e); 28.201 } 28.202 @@ -193,10 +166,7 @@ 28.203 @Override 28.204 public final void addFirst(final Object e) { 28.205 try { 28.206 - final InvokeByName unshiftInvoker = getUNSHIFT(); 28.207 - final Object fn = unshiftInvoker.getGetter().invokeExact(obj); 28.208 - checkFunction(fn, unshiftInvoker); 28.209 - unshiftInvoker.getInvoker().invokeExact(fn, obj, e); 28.210 + getUnshiftInvoker().invokeExact(getFunction("unshift"), obj, e); 28.211 } catch(RuntimeException | Error ex) { 28.212 throw ex; 28.213 } catch(final Throwable t) { 28.214 @@ -207,10 +177,7 @@ 28.215 @Override 28.216 public final void addLast(final Object e) { 28.217 try { 28.218 - final InvokeByName pushInvoker = getPUSH(); 28.219 - final Object fn = pushInvoker.getGetter().invokeExact(obj); 28.220 - checkFunction(fn, pushInvoker); 28.221 - pushInvoker.getInvoker().invokeExact(fn, obj, e); 28.222 + getPushInvoker().invokeExact(getFunction("push"), obj, e); 28.223 } catch(RuntimeException | Error ex) { 28.224 throw ex; 28.225 } catch(final Throwable t) { 28.226 @@ -228,10 +195,7 @@ 28.227 } else { 28.228 final int size = size(); 28.229 if(index < size) { 28.230 - final InvokeByName spliceAddInvoker = getSPLICE_ADD(); 28.231 - final Object fn = spliceAddInvoker.getGetter().invokeExact(obj); 28.232 - checkFunction(fn, spliceAddInvoker); 28.233 - spliceAddInvoker.getInvoker().invokeExact(fn, obj, index, 0, e); 28.234 + getSpliceAddInvoker().invokeExact(obj.getMember("splice"), obj, index, 0, e); 28.235 } else if(index == size) { 28.236 addLast(e); 28.237 } else { 28.238 @@ -244,10 +208,12 @@ 28.239 throw new RuntimeException(t); 28.240 } 28.241 } 28.242 - private static void checkFunction(final Object fn, final InvokeByName invoke) { 28.243 + private Object getFunction(final String name) { 28.244 + final Object fn = obj.getMember(name); 28.245 if(!(Bootstrap.isCallable(fn))) { 28.246 - throw new UnsupportedOperationException("The script object doesn't have a function named " + invoke.getName()); 28.247 + throw new UnsupportedOperationException("The script object doesn't have a function named " + name); 28.248 } 28.249 + return fn; 28.250 } 28.251 28.252 private static IndexOutOfBoundsException invalidIndex(final int index) { 28.253 @@ -321,10 +287,7 @@ 28.254 28.255 private Object invokeShift() { 28.256 try { 28.257 - final InvokeByName shiftInvoker = getSHIFT(); 28.258 - final Object fn = shiftInvoker.getGetter().invokeExact(obj); 28.259 - checkFunction(fn, shiftInvoker); 28.260 - return shiftInvoker.getInvoker().invokeExact(fn, obj); 28.261 + return getShiftInvoker().invokeExact(getFunction("shift"), obj); 28.262 } catch(RuntimeException | Error ex) { 28.263 throw ex; 28.264 } catch(final Throwable t) { 28.265 @@ -334,10 +297,7 @@ 28.266 28.267 private Object invokePop() { 28.268 try { 28.269 - final InvokeByName popInvoker = getPOP(); 28.270 - final Object fn = popInvoker.getGetter().invokeExact(obj); 28.271 - checkFunction(fn, popInvoker); 28.272 - return popInvoker.getInvoker().invokeExact(fn, obj); 28.273 + return getPopInvoker().invokeExact(getFunction("pop"), obj); 28.274 } catch(RuntimeException | Error ex) { 28.275 throw ex; 28.276 } catch(final Throwable t) { 28.277 @@ -352,10 +312,7 @@ 28.278 28.279 private void invokeSpliceRemove(final int fromIndex, final int count) { 28.280 try { 28.281 - final InvokeByName spliceRemoveInvoker = getSPLICE_REMOVE(); 28.282 - final Object fn = spliceRemoveInvoker.getGetter().invokeExact(obj); 28.283 - checkFunction(fn, spliceRemoveInvoker); 28.284 - spliceRemoveInvoker.getInvoker().invokeExact(fn, obj, fromIndex, count); 28.285 + getSpliceRemoveInvoker().invokeExact(getFunction("splice"), obj, fromIndex, count); 28.286 } catch(RuntimeException | Error ex) { 28.287 throw ex; 28.288 } catch(final Throwable t) { 28.289 @@ -443,12 +400,24 @@ 28.290 28.291 private static boolean removeOccurrence(final Object o, final Iterator<Object> it) { 28.292 while(it.hasNext()) { 28.293 - final Object e = it.next(); 28.294 - if(o == null ? e == null : o.equals(e)) { 28.295 + if(Objects.equals(o, it.next())) { 28.296 it.remove(); 28.297 return true; 28.298 } 28.299 } 28.300 return false; 28.301 } 28.302 + 28.303 + private static Callable<MethodHandle> invokerCreator(final Class<?> rtype, final Class<?>... ptypes) { 28.304 + return new Callable<MethodHandle>() { 28.305 + @Override 28.306 + public MethodHandle call() { 28.307 + return Bootstrap.createDynamicInvoker("dyn:call", rtype, ptypes); 28.308 + } 28.309 + }; 28.310 + } 28.311 + 28.312 + private static MethodHandle getDynamicInvoker(final Object key, final Callable<MethodHandle> creator) { 28.313 + return Context.getGlobal().getDynamicInvoker(key, creator); 28.314 + } 28.315 }
29.1 --- a/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java Thu May 28 20:55:21 2015 -0700 29.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java Wed Jun 03 20:30:20 2015 -0700 29.3 @@ -1,5 +1,5 @@ 29.4 /* 29.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 29.6 + * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. 29.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.8 * 29.9 * This code is free software; you can redistribute it and/or modify it 29.10 @@ -34,10 +34,13 @@ 29.11 import java.io.IOException; 29.12 import java.io.InputStreamReader; 29.13 import java.io.OutputStreamWriter; 29.14 +import java.io.StreamTokenizer; 29.15 +import java.io.StringReader; 29.16 import java.lang.invoke.MethodHandle; 29.17 import java.lang.invoke.MethodHandles; 29.18 +import java.util.ArrayList; 29.19 +import java.util.List; 29.20 import java.util.Map; 29.21 -import java.util.StringTokenizer; 29.22 29.23 /** 29.24 * Global functions supported only in scripting mode. 29.25 @@ -133,15 +136,8 @@ 29.26 // Current global is need to fetch additional inputs and for additional results. 29.27 final ScriptObject global = Context.getGlobal(); 29.28 29.29 - // Break exec string into tokens. 29.30 - final StringTokenizer tokenizer = new StringTokenizer(JSType.toString(string)); 29.31 - final String[] cmdArray = new String[tokenizer.countTokens()]; 29.32 - for (int i = 0; tokenizer.hasMoreTokens(); i++) { 29.33 - cmdArray[i] = tokenizer.nextToken(); 29.34 - } 29.35 - 29.36 // Set up initial process. 29.37 - final ProcessBuilder processBuilder = new ProcessBuilder(cmdArray); 29.38 + final ProcessBuilder processBuilder = new ProcessBuilder(tokenizeCommandLine(JSType.toString(string))); 29.39 29.40 // Current ENV property state. 29.41 final Object env = global.get(ENV_NAME); 29.42 @@ -239,4 +235,43 @@ 29.43 private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) { 29.44 return MH.findStatic(MethodHandles.lookup(), ScriptingFunctions.class, name, MH.type(rtype, types)); 29.45 } 29.46 + 29.47 + /** 29.48 + * Break an exec string into tokens, honoring quoted arguments and escaped 29.49 + * spaces. 29.50 + * 29.51 + * @param execString a {@link String} with the command line to execute. 29.52 + * @return a {@link List} of {@link String}s representing the tokens that 29.53 + * constitute the command line. 29.54 + * @throws IOException in case {@link StreamTokenizer#nextToken()} raises it. 29.55 + */ 29.56 + public static List<String> tokenizeCommandLine(final String execString) throws IOException { 29.57 + final StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(execString)); 29.58 + tokenizer.resetSyntax(); 29.59 + tokenizer.wordChars(0, 255); 29.60 + tokenizer.whitespaceChars(0, ' '); 29.61 + tokenizer.commentChar('#'); 29.62 + tokenizer.quoteChar('"'); 29.63 + tokenizer.quoteChar('\''); 29.64 + final List<String> cmdList = new ArrayList<>(); 29.65 + final StringBuilder toAppend = new StringBuilder(); 29.66 + while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) { 29.67 + final String s = tokenizer.sval; 29.68 + // The tokenizer understands about honoring quoted strings and recognizes 29.69 + // them as one token that possibly contains multiple space-separated words. 29.70 + // It does not recognize quoted spaces, though, and will split after the 29.71 + // escaping \ character. This is handled here. 29.72 + if (s.endsWith("\\")) { 29.73 + // omit trailing \, append space instead 29.74 + toAppend.append(s.substring(0, s.length() - 1)).append(' '); 29.75 + } else { 29.76 + cmdList.add(toAppend.append(s).toString()); 29.77 + toAppend.setLength(0); 29.78 + } 29.79 + } 29.80 + if (toAppend.length() != 0) { 29.81 + cmdList.add(toAppend.toString()); 29.82 + } 29.83 + return cmdList; 29.84 + } 29.85 }
30.1 --- a/src/jdk/nashorn/internal/runtime/StoredScript.java Thu May 28 20:55:21 2015 -0700 30.2 +++ b/src/jdk/nashorn/internal/runtime/StoredScript.java Wed Jun 03 20:30:20 2015 -0700 30.3 @@ -58,7 +58,7 @@ 30.4 * @param compilationId compilation id 30.5 * @param mainClassName main class name 30.6 * @param classBytes map of class names to class bytes 30.7 - * @param initializers initializer map, id -> FunctionInitializer 30.8 + * @param initializers initializer map, id -> FunctionInitializer 30.9 * @param constants constants array 30.10 */ 30.11 public StoredScript(final int compilationId, final String mainClassName, final Map<String, byte[]> classBytes, final Map<Integer, FunctionInitializer> initializers, final Object[] constants) {
31.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java Thu May 28 20:55:21 2015 -0700 31.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java Wed Jun 03 20:30:20 2015 -0700 31.3 @@ -276,7 +276,7 @@ 31.4 /** 31.5 * Align an array size up to the nearest array chunk size 31.6 * @param size size required 31.7 - * @return size given, always >= size 31.8 + * @return size given, always >= size 31.9 */ 31.10 protected final static int alignUp(final int size) { 31.11 return size + CHUNK_SIZE - 1 & ~(CHUNK_SIZE - 1);
32.1 --- a/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Thu May 28 20:55:21 2015 -0700 32.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Wed Jun 03 20:30:20 2015 -0700 32.3 @@ -182,14 +182,13 @@ 32.4 32.5 @Override 32.6 public ArrayData convert(final Class<?> type) { 32.7 - if (type == Integer.class) { 32.8 + if (type == Integer.class || type == Byte.class || type == Short.class) { 32.9 return this; 32.10 } else if (type == Long.class) { 32.11 return convertToLong(); 32.12 - } else if (type == Double.class) { 32.13 + } else if (type == Double.class || type == Float.class) { 32.14 return convertToDouble(); 32.15 } else { 32.16 - assert type == null || (!Number.class.isAssignableFrom(type) && !type.isPrimitive()); 32.17 return convertToObject(); 32.18 } 32.19 }
33.1 --- a/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Thu May 28 20:55:21 2015 -0700 33.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Wed Jun 03 20:30:20 2015 -0700 33.3 @@ -120,11 +120,11 @@ 33.4 33.5 @Override 33.6 public ContinuousArrayData convert(final Class<?> type) { 33.7 - if (type == Integer.class || type == Long.class) { 33.8 + if (type == Integer.class || type == Long.class || type == Byte.class || type == Short.class) { 33.9 return this; 33.10 } 33.11 final int len = (int)length(); 33.12 - if (type == Double.class) { 33.13 + if (type == Double.class || type == Float.class) { 33.14 return new NumberArrayData(toDoubleArray(), len); 33.15 } 33.16 return new ObjectArrayData(toObjectArray(false), len); 33.17 @@ -171,7 +171,8 @@ 33.18 33.19 @Override 33.20 public ArrayData set(final int index, final Object value, final boolean strict) { 33.21 - if (value instanceof Long || value instanceof Integer) { 33.22 + if (value instanceof Long || value instanceof Integer || 33.23 + value instanceof Byte || value instanceof Short) { 33.24 return set(index, ((Number)value).longValue(), strict); 33.25 } else if (value == ScriptRuntime.UNDEFINED) { 33.26 return new UndefinedArrayFilter(this).set(index, value, strict);
34.1 --- a/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Thu May 28 20:55:21 2015 -0700 34.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Wed Jun 03 20:30:20 2015 -0700 34.3 @@ -29,6 +29,7 @@ 34.4 import static jdk.nashorn.internal.lookup.Lookup.MH; 34.5 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; 34.6 34.7 +import jdk.internal.dynalink.support.TypeUtilities; 34.8 import java.lang.invoke.MethodHandle; 34.9 import java.lang.invoke.MethodHandles; 34.10 import java.util.Arrays; 34.11 @@ -104,9 +105,14 @@ 34.12 return super.asArrayOfType(componentType); 34.13 } 34.14 34.15 + private static boolean canWiden(final Class<?> type) { 34.16 + return TypeUtilities.isWrapperType(type) && 34.17 + type != Boolean.class && type != Character.class; 34.18 + } 34.19 + 34.20 @Override 34.21 public ContinuousArrayData convert(final Class<?> type) { 34.22 - if (type != Double.class && type != Integer.class && type != Long.class) { 34.23 + if (! canWiden(type)) { 34.24 final int len = (int)length(); 34.25 return new ObjectArrayData(toObjectArray(false), len); 34.26 } 34.27 @@ -154,7 +160,7 @@ 34.28 34.29 @Override 34.30 public ArrayData set(final int index, final Object value, final boolean strict) { 34.31 - if (value instanceof Double || value instanceof Integer || value instanceof Long) { 34.32 + if (value instanceof Double || (value != null && canWiden(value.getClass()))) { 34.33 return set(index, ((Number)value).doubleValue(), strict); 34.34 } else if (value == UNDEFINED) { 34.35 return new UndefinedArrayFilter(this).set(index, value, strict);
35.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java Thu May 28 20:55:21 2015 -0700 35.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java Wed Jun 03 20:30:20 2015 -0700 35.3 @@ -29,13 +29,15 @@ 35.4 35.5 import java.lang.invoke.MethodHandle; 35.6 import java.lang.invoke.MethodHandles; 35.7 -import java.lang.invoke.MethodHandles.Lookup; 35.8 +import java.lang.invoke.MethodType; 35.9 import java.lang.reflect.Modifier; 35.10 import java.security.AccessController; 35.11 import java.security.PrivilegedAction; 35.12 +import java.util.Collection; 35.13 import java.util.Deque; 35.14 import java.util.List; 35.15 import java.util.Map; 35.16 +import java.util.Queue; 35.17 import javax.script.Bindings; 35.18 import jdk.internal.dynalink.CallSiteDescriptor; 35.19 import jdk.internal.dynalink.linker.ConversionComparator; 35.20 @@ -47,11 +49,13 @@ 35.21 import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker; 35.22 import jdk.internal.dynalink.support.Guards; 35.23 import jdk.internal.dynalink.support.LinkerServicesImpl; 35.24 +import jdk.internal.dynalink.support.Lookup; 35.25 import jdk.nashorn.api.scripting.JSObject; 35.26 import jdk.nashorn.api.scripting.ScriptObjectMirror; 35.27 import jdk.nashorn.api.scripting.ScriptUtils; 35.28 import jdk.nashorn.internal.objects.NativeArray; 35.29 import jdk.nashorn.internal.runtime.JSType; 35.30 +import jdk.nashorn.internal.runtime.ListAdapter; 35.31 import jdk.nashorn.internal.runtime.ScriptFunction; 35.32 import jdk.nashorn.internal.runtime.ScriptObject; 35.33 import jdk.nashorn.internal.runtime.Undefined; 35.34 @@ -167,7 +171,7 @@ 35.35 return null; 35.36 } 35.37 35.38 - private static Lookup getCurrentLookup() { 35.39 + private static java.lang.invoke.MethodHandles.Lookup getCurrentLookup() { 35.40 final LinkRequest currentRequest = AccessController.doPrivileged(new PrivilegedAction<LinkRequest>() { 35.41 @Override 35.42 public LinkRequest run() { 35.43 @@ -179,12 +183,12 @@ 35.44 35.45 /** 35.46 * Returns a guarded invocation that converts from a source type that is NativeArray to a Java array or List or 35.47 - * Deque type. 35.48 + * Queue or Deque or Collection type. 35.49 * @param sourceType the source type (presumably NativeArray a superclass of it) 35.50 - * @param targetType the target type (presumably an array type, or List or Deque) 35.51 + * @param targetType the target type (presumably an array type, or List or Queue, or Deque, or Collection) 35.52 * @return a guarded invocation that converts from the source type to the target type. null is returned if 35.53 * either the source type is neither NativeArray, nor a superclass of it, or if the target type is not an array 35.54 - * type, List, or Deque. 35.55 + * type, List, Queue, Deque, or Collection. 35.56 */ 35.57 private static GuardedInvocation getArrayConverter(final Class<?> sourceType, final Class<?> targetType) { 35.58 final boolean isSourceTypeNativeArray = sourceType == NativeArray.class; 35.59 @@ -195,12 +199,14 @@ 35.60 final MethodHandle guard = isSourceTypeGeneric ? IS_NATIVE_ARRAY : null; 35.61 if(targetType.isArray()) { 35.62 return new GuardedInvocation(ARRAY_CONVERTERS.get(targetType), guard); 35.63 - } 35.64 - if(targetType == List.class) { 35.65 - return new GuardedInvocation(JSType.TO_JAVA_LIST.methodHandle(), guard); 35.66 - } 35.67 - if(targetType == Deque.class) { 35.68 - return new GuardedInvocation(JSType.TO_JAVA_DEQUE.methodHandle(), guard); 35.69 + } else if(targetType == List.class) { 35.70 + return new GuardedInvocation(TO_LIST, guard); 35.71 + } else if(targetType == Deque.class) { 35.72 + return new GuardedInvocation(TO_DEQUE, guard); 35.73 + } else if(targetType == Queue.class) { 35.74 + return new GuardedInvocation(TO_QUEUE, guard); 35.75 + } else if(targetType == Collection.class) { 35.76 + return new GuardedInvocation(TO_COLLECTION, guard); 35.77 } 35.78 } 35.79 return null; 35.80 @@ -216,10 +222,11 @@ 35.81 // Could've also used (targetType.isAssignableFrom(ScriptObjectMirror.class) && targetType != Object.class) but 35.82 // it's probably better to explicitly spell out the supported target types 35.83 if (targetType == Map.class || targetType == Bindings.class || targetType == JSObject.class || targetType == ScriptObjectMirror.class) { 35.84 - if(ScriptObject.class.isAssignableFrom(sourceType)) { 35.85 + if (ScriptObject.class.isAssignableFrom(sourceType)) { 35.86 return new GuardedInvocation(CREATE_MIRROR); 35.87 + } else if (sourceType.isAssignableFrom(ScriptObject.class) || sourceType.isInterface()) { 35.88 + return new GuardedInvocation(CREATE_MIRROR, IS_SCRIPT_OBJECT); 35.89 } 35.90 - return new GuardedInvocation(CREATE_MIRROR, IS_SCRIPT_OBJECT); 35.91 } 35.92 return null; 35.93 } 35.94 @@ -285,6 +292,23 @@ 35.95 private static final MethodHandle IS_NASHORN_OR_UNDEFINED_TYPE = findOwnMH("isNashornTypeOrUndefined", Boolean.TYPE, Object.class); 35.96 private static final MethodHandle CREATE_MIRROR = findOwnMH("createMirror", Object.class, Object.class); 35.97 35.98 + private static final MethodHandle TO_COLLECTION; 35.99 + private static final MethodHandle TO_DEQUE; 35.100 + private static final MethodHandle TO_LIST; 35.101 + private static final MethodHandle TO_QUEUE; 35.102 + static { 35.103 + final MethodHandle listAdapterCreate = new Lookup(MethodHandles.lookup()).findStatic( 35.104 + ListAdapter.class, "create", MethodType.methodType(ListAdapter.class, Object.class)); 35.105 + TO_COLLECTION = asReturning(listAdapterCreate, Collection.class); 35.106 + TO_DEQUE = asReturning(listAdapterCreate, Deque.class); 35.107 + TO_LIST = asReturning(listAdapterCreate, List.class); 35.108 + TO_QUEUE = asReturning(listAdapterCreate, Queue.class); 35.109 + } 35.110 + 35.111 + private static MethodHandle asReturning(final MethodHandle mh, final Class<?> nrtype) { 35.112 + return mh.asType(mh.type().changeReturnType(nrtype)); 35.113 + } 35.114 + 35.115 @SuppressWarnings("unused") 35.116 private static boolean isNashornTypeOrUndefined(final Object obj) { 35.117 return obj instanceof ScriptObject || obj instanceof Undefined;
36.1 --- a/src/jdk/nashorn/internal/runtime/options/Options.java Thu May 28 20:55:21 2015 -0700 36.2 +++ b/src/jdk/nashorn/internal/runtime/options/Options.java Wed Jun 03 20:30:20 2015 -0700 36.3 @@ -424,9 +424,17 @@ 36.4 public void process(final String[] args) { 36.5 final LinkedList<String> argList = new LinkedList<>(); 36.6 addSystemProperties(NASHORN_ARGS_PREPEND_PROPERTY, argList); 36.7 + processArgList(argList); 36.8 + assert argList.isEmpty(); 36.9 Collections.addAll(argList, args); 36.10 + processArgList(argList); 36.11 + assert argList.isEmpty(); 36.12 addSystemProperties(NASHORN_ARGS_PROPERTY, argList); 36.13 + processArgList(argList); 36.14 + assert argList.isEmpty(); 36.15 + } 36.16 36.17 + private void processArgList(final LinkedList<String> argList) { 36.18 while (!argList.isEmpty()) { 36.19 final String arg = argList.remove(0); 36.20
37.1 --- a/src/jdk/nashorn/internal/runtime/resources/Messages.properties Thu May 28 20:55:21 2015 -0700 37.2 +++ b/src/jdk/nashorn/internal/runtime/resources/Messages.properties Wed Jun 03 20:30:20 2015 -0700 37.3 @@ -121,7 +121,7 @@ 37.4 type.error.cannot.get.default.number=Cannot get default number value 37.5 type.error.cant.apply.with.to.null=Cannot apply "with" to null 37.6 type.error.cant.apply.with.to.undefined=Cannot apply "with" to undefined 37.7 -type.error.cant.apply.with.to.non.scriptobject=Cannot apply "with" to non script object 37.8 +type.error.cant.apply.with.to.non.scriptobject=Cannot apply "with" to non script object. Consider using "with(Object.bindProperties('{'}, nonScriptObject))". 37.9 type.error.in.with.non.object=Right hand side of "in" cannot be non-Object, found {0} 37.10 type.error.prototype.not.an.object="prototype" of {0} is not an Object, it is {1} 37.11 type.error.cant.load.script=Cannot load script from {0}
38.1 --- a/test/script/basic/8024180/with_java_object.js.EXPECTED Thu May 28 20:55:21 2015 -0700 38.2 +++ b/test/script/basic/8024180/with_java_object.js.EXPECTED Wed Jun 03 20:30:20 2015 -0700 38.3 @@ -1,1 +1,1 @@ 38.4 -TypeError: Cannot apply "with" to non script object 38.5 +TypeError: Cannot apply "with" to non script object. Consider using "with(Object.bindProperties({}, nonScriptObject))".
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 39.2 +++ b/test/script/basic/JDK-8007456.js Wed Jun 03 20:30:20 2015 -0700 39.3 @@ -0,0 +1,35 @@ 39.4 +/* 39.5 + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.7 + * 39.8 + * This code is free software; you can redistribute it and/or modify it 39.9 + * under the terms of the GNU General Public License version 2 only, as 39.10 + * published by the Free Software Foundation. 39.11 + * 39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 39.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39.15 + * version 2 for more details (a copy is included in the LICENSE file that 39.16 + * accompanied this code). 39.17 + * 39.18 + * You should have received a copy of the GNU General Public License version 39.19 + * 2 along with this work; if not, write to the Free Software Foundation, 39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 39.21 + * 39.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 39.23 + * or visit www.oracle.com if you need additional information or have any 39.24 + * questions. 39.25 + */ 39.26 + 39.27 +/** 39.28 + * JDK-8007456: Nashorn test framework argument does not handle quoted strings 39.29 + * 39.30 + * @test 39.31 + * @argument "hello world" 39.32 + * @argument "This has spaces" 39.33 + * @run 39.34 + */ 39.35 + 39.36 +print(arguments.length); 39.37 +print(arguments[0]); 39.38 +print(arguments[1]);
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 40.2 +++ b/test/script/basic/JDK-8007456.js.EXPECTED Wed Jun 03 20:30:20 2015 -0700 40.3 @@ -0,0 +1,3 @@ 40.4 +2 40.5 +hello world 40.6 +This has spaces
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 41.2 +++ b/test/script/basic/JDK-8071928.js Wed Jun 03 20:30:20 2015 -0700 41.3 @@ -0,0 +1,57 @@ 41.4 +/* 41.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41.7 + * 41.8 + * This code is free software; you can redistribute it and/or modify it 41.9 + * under the terms of the GNU General Public License version 2 only, as 41.10 + * published by the Free Software Foundation. 41.11 + * 41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 41.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41.15 + * version 2 for more details (a copy is included in the LICENSE file that 41.16 + * accompanied this code). 41.17 + * 41.18 + * You should have received a copy of the GNU General Public License version 41.19 + * 2 along with this work; if not, write to the Free Software Foundation, 41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 41.21 + * 41.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 41.23 + * or visit www.oracle.com if you need additional information or have any 41.24 + * questions. 41.25 + */ 41.26 + 41.27 +/** 41.28 + * JDK-8071928: Instance properties with getters returning wrong values 41.29 + * 41.30 + * @test 41.31 + * @run 41.32 + */ 41.33 + 41.34 + 41.35 +var types = {}; 41.36 + 41.37 +function Type() {} 41.38 + 41.39 +Type.prototype.getName = function() { 41.40 + return this._name; 41.41 +}; 41.42 + 41.43 +function defineType(init) { 41.44 + return Object.create(Type.prototype, { 41.45 + _name: { get: function() { return init.name; } } 41.46 + }); 41.47 +} 41.48 + 41.49 +types.A = defineType({ name: 'A' }); 41.50 +types.B = defineType({ name: 'B' }); 41.51 +types.C = defineType({ name: 'C' }); 41.52 +types.D = defineType({ name: 'D' }); 41.53 + 41.54 +var keys = Object.keys(types); 41.55 +for (var i = 0; i < keys.length; i++) { 41.56 + var t = types[keys[i]]; 41.57 + if (t.getName() != keys[i]) { 41.58 + throw 'wrong name for ' + keys[i] + ': ' + t.getName(); 41.59 + } 41.60 +}
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 42.2 +++ b/test/script/basic/JDK-8073846.js Wed Jun 03 20:30:20 2015 -0700 42.3 @@ -0,0 +1,54 @@ 42.4 +/* 42.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 42.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42.7 + * 42.8 + * This code is free software; you can redistribute it and/or modify it 42.9 + * under the terms of the GNU General Public License version 2 only, as 42.10 + * published by the Free Software Foundation. 42.11 + * 42.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 42.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 42.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42.15 + * version 2 for more details (a copy is included in the LICENSE file that 42.16 + * accompanied this code). 42.17 + * 42.18 + * You should have received a copy of the GNU General Public License version 42.19 + * 2 along with this work; if not, write to the Free Software Foundation, 42.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 42.21 + * 42.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 42.23 + * or visit www.oracle.com if you need additional information or have any 42.24 + * questions. 42.25 + */ 42.26 + 42.27 +/** 42.28 + * JDK-8073846: Javascript for-in loop returned extra keys 42.29 + * 42.30 + * @test 42.31 + * @run 42.32 + */ 42.33 + 42.34 +var obj = {}; 42.35 + 42.36 +var list = [ 42.37 + '2100000', 42.38 + '420000', 42.39 + '430000' 42.40 +]; 42.41 + 42.42 +for (var i = 0; i < list.length; i++) { 42.43 + if (obj[list[i]]) print("duplicate: " + list[i]); 42.44 + obj[list[i]] = 'obj' + list[i] 42.45 +} 42.46 + 42.47 +var count = 0; 42.48 +for (var a in obj) { 42.49 + count++; 42.50 + if ('obj' + a !== obj[a]) { 42.51 + throw 'wrong key or value: ' + a + ', ' + obj[a]; 42.52 + } 42.53 +} 42.54 + 42.55 +if (count !== 3) { 42.56 + throw 'wrong entry count: ' + count; 42.57 +}
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 43.2 +++ b/test/script/basic/JDK-8079145.js Wed Jun 03 20:30:20 2015 -0700 43.3 @@ -0,0 +1,89 @@ 43.4 +/* 43.5 + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 43.7 + * 43.8 + * This code is free software; you can redistribute it and/or modify it 43.9 + * under the terms of the GNU General Public License version 2 only, as 43.10 + * published by the Free Software Foundation. 43.11 + * 43.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 43.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 43.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43.15 + * version 2 for more details (a copy is included in the LICENSE file that 43.16 + * accompanied this code). 43.17 + * 43.18 + * You should have received a copy of the GNU General Public License version 43.19 + * 2 along with this work; if not, write to the Free Software Foundation, 43.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 43.21 + * 43.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 43.23 + * or visit www.oracle.com if you need additional information or have any 43.24 + * questions. 43.25 + */ 43.26 + 43.27 +/** 43.28 + * JDK-8079145: jdk.nashorn.internal.runtime.arrays.IntArrayData.convert assertion 43.29 + * 43.30 + * @test 43.31 + * @fork 43.32 + * @option -Dnashorn.debug=true 43.33 + * @run 43.34 + */ 43.35 + 43.36 +var Byte = java.lang.Byte; 43.37 +var Short = java.lang.Short; 43.38 +var Integer = java.lang.Integer; 43.39 +var Long = java.lang.Long; 43.40 +var Float = java.lang.Float; 43.41 +var Double = java.lang.Double; 43.42 +var Character = java.lang.Character; 43.43 + 43.44 +function checkWiden(arr, value, name) { 43.45 + switch (typeof value) { 43.46 + case 'object': 43.47 + case 'undefined': 43.48 + print(name + ": check widen for " + value); 43.49 + break; 43.50 + default: 43.51 + print(name + ": check widen for " + value + 43.52 + " [" + Debug.getClass(value) + "]"); 43.53 + } 43.54 + 43.55 + arr[0] = value; 43.56 +} 43.57 + 43.58 +function checkIntWiden(value) { 43.59 + checkWiden([34], value, "int array"); 43.60 +} 43.61 + 43.62 +function checkLongWiden(value) { 43.63 + checkWiden([Integer.MAX_VALUE + 1], value, "long array"); 43.64 +} 43.65 + 43.66 +function checkNumberWiden(value) { 43.67 + checkWiden([Math.PI], value, "number array"); 43.68 +} 43.69 + 43.70 +function checkObjectWiden(value) { 43.71 + checkWiden([null], value, "object array"); 43.72 +} 43.73 + 43.74 +var values = [{}, null, undefined, false, true, new Byte(34), 43.75 + new Integer(344454), new Long(454545), new Long(Integer.MAX_VALUE + 1), 43.76 + new Float(34.3), new Double(Math.PI), new Character('s')]; 43.77 + 43.78 +for each (var v in values) { 43.79 + checkIntWiden(v); 43.80 +} 43.81 + 43.82 +for each (var v in values) { 43.83 + checkLongWiden(v); 43.84 +} 43.85 + 43.86 +for each (var v in values) { 43.87 + checkNumberWiden(v); 43.88 +} 43.89 + 43.90 +for each (var v in values) { 43.91 + checkObjectWiden(v); 43.92 +}
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 44.2 +++ b/test/script/basic/JDK-8079145.js.EXPECTED Wed Jun 03 20:30:20 2015 -0700 44.3 @@ -0,0 +1,48 @@ 44.4 +int array: check widen for [object Object] 44.5 +int array: check widen for null 44.6 +int array: check widen for undefined 44.7 +int array: check widen for false [class java.lang.Boolean] 44.8 +int array: check widen for true [class java.lang.Boolean] 44.9 +int array: check widen for 34 [class java.lang.Byte] 44.10 +int array: check widen for 344454 [class java.lang.Integer] 44.11 +int array: check widen for 454545 [class java.lang.Long] 44.12 +int array: check widen for 2147483648 [class java.lang.Long] 44.13 +int array: check widen for 34.29999923706055 [class java.lang.Float] 44.14 +int array: check widen for 3.141592653589793 [class java.lang.Double] 44.15 +int array: check widen for s 44.16 +long array: check widen for [object Object] 44.17 +long array: check widen for null 44.18 +long array: check widen for undefined 44.19 +long array: check widen for false [class java.lang.Boolean] 44.20 +long array: check widen for true [class java.lang.Boolean] 44.21 +long array: check widen for 34 [class java.lang.Byte] 44.22 +long array: check widen for 344454 [class java.lang.Integer] 44.23 +long array: check widen for 454545 [class java.lang.Long] 44.24 +long array: check widen for 2147483648 [class java.lang.Long] 44.25 +long array: check widen for 34.29999923706055 [class java.lang.Float] 44.26 +long array: check widen for 3.141592653589793 [class java.lang.Double] 44.27 +long array: check widen for s 44.28 +number array: check widen for [object Object] 44.29 +number array: check widen for null 44.30 +number array: check widen for undefined 44.31 +number array: check widen for false [class java.lang.Boolean] 44.32 +number array: check widen for true [class java.lang.Boolean] 44.33 +number array: check widen for 34 [class java.lang.Byte] 44.34 +number array: check widen for 344454 [class java.lang.Integer] 44.35 +number array: check widen for 454545 [class java.lang.Long] 44.36 +number array: check widen for 2147483648 [class java.lang.Long] 44.37 +number array: check widen for 34.29999923706055 [class java.lang.Float] 44.38 +number array: check widen for 3.141592653589793 [class java.lang.Double] 44.39 +number array: check widen for s 44.40 +object array: check widen for [object Object] 44.41 +object array: check widen for null 44.42 +object array: check widen for undefined 44.43 +object array: check widen for false [class java.lang.Boolean] 44.44 +object array: check widen for true [class java.lang.Boolean] 44.45 +object array: check widen for 34 [class java.lang.Byte] 44.46 +object array: check widen for 344454 [class java.lang.Integer] 44.47 +object array: check widen for 454545 [class java.lang.Long] 44.48 +object array: check widen for 2147483648 [class java.lang.Long] 44.49 +object array: check widen for 34.29999923706055 [class java.lang.Float] 44.50 +object array: check widen for 3.141592653589793 [class java.lang.Double] 44.51 +object array: check widen for s
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 45.2 +++ b/test/script/basic/JDK-8079424.js Wed Jun 03 20:30:20 2015 -0700 45.3 @@ -0,0 +1,50 @@ 45.4 +/* 45.5 + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 45.7 + * 45.8 + * This code is free software; you can redistribute it and/or modify it 45.9 + * under the terms of the GNU General Public License version 2 only, as 45.10 + * published by the Free Software Foundation. 45.11 + * 45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 45.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45.15 + * version 2 for more details (a copy is included in the LICENSE file that 45.16 + * accompanied this code). 45.17 + * 45.18 + * You should have received a copy of the GNU General Public License version 45.19 + * 2 along with this work; if not, write to the Free Software Foundation, 45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 45.21 + * 45.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 45.23 + * or visit www.oracle.com if you need additional information or have any 45.24 + * questions. 45.25 + */ 45.26 + 45.27 +/** 45.28 + * JDK-8079424: code generator for discarded boolean logical operation has an extra pop 45.29 + * 45.30 + * @test 45.31 + * @run 45.32 + */ 45.33 + 45.34 +// If the compiler manages to compile all of these, the test passes. 45.35 +void (true && true); 45.36 +void (true && false); 45.37 +void (false && true); 45.38 +void (false && false); 45.39 + 45.40 +void (true || true); 45.41 +void (true || false); 45.42 +void (false || true); 45.43 +void (false || false); 45.44 + 45.45 +void (1 && 1); 45.46 +void (1 && 0); 45.47 +void (0 && 1); 45.48 +void (0 && 0); 45.49 + 45.50 +void (1 || 1); 45.51 +void (1 || 0); 45.52 +void (0 || 1); 45.53 +void (0 || 0);
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 46.2 +++ b/test/script/basic/JDK-8080848.js Wed Jun 03 20:30:20 2015 -0700 46.3 @@ -0,0 +1,37 @@ 46.4 +/* 46.5 + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 46.7 + * 46.8 + * This code is free software; you can redistribute it and/or modify it 46.9 + * under the terms of the GNU General Public License version 2 only, as 46.10 + * published by the Free Software Foundation. 46.11 + * 46.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 46.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 46.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 46.15 + * version 2 for more details (a copy is included in the LICENSE file that 46.16 + * accompanied this code). 46.17 + * 46.18 + * You should have received a copy of the GNU General Public License version 46.19 + * 2 along with this work; if not, write to the Free Software Foundation, 46.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 46.21 + * 46.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 46.23 + * or visit www.oracle.com if you need additional information or have any 46.24 + * questions. 46.25 + */ 46.26 + 46.27 +/** 46.28 + * JDK-8080848: delete of bound Java method property results in crash 46.29 + * 46.30 + * @test 46.31 + * @run 46.32 + */ 46.33 + 46.34 +var obj = Object.bindProperties({}, new java.io.File(".")); 46.35 + 46.36 +delete obj.wait; 46.37 + 46.38 +if (typeof obj.wait != 'undefined') { 46.39 + throw new Error("obj.wait was not deleted"); 46.40 +}
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/test/script/basic/JDK-8081156.js Wed Jun 03 20:30:20 2015 -0700 47.3 @@ -0,0 +1,46 @@ 47.4 +/* 47.5 + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 47.7 + * 47.8 + * This code is free software; you can redistribute it and/or modify it 47.9 + * under the terms of the GNU General Public License version 2 only, as 47.10 + * published by the Free Software Foundation. 47.11 + * 47.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 47.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 47.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47.15 + * version 2 for more details (a copy is included in the LICENSE file that 47.16 + * accompanied this code). 47.17 + * 47.18 + * You should have received a copy of the GNU General Public License version 47.19 + * 2 along with this work; if not, write to the Free Software Foundation, 47.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 47.21 + * 47.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 47.23 + * or visit www.oracle.com if you need additional information or have any 47.24 + * questions. 47.25 + */ 47.26 + 47.27 +/** 47.28 + * JDK-8081156: jjs "nashorn.args" system property is not effective when script arguments are passed 47.29 + * 47.30 + * @test 47.31 + * @fork 47.32 + * @option -Dnashorn.args=-strict 47.33 + * @argument foo 47.34 + * @argument bar 47.35 + * @run 47.36 + */ 47.37 + 47.38 +try { 47.39 + x = 14; 47.40 + throw new Error("should have thrown ReferenceError"); 47.41 +} catch (e) { 47.42 + if (! (e instanceof ReferenceError)) { 47.43 + throw e; 47.44 + } 47.45 +} 47.46 + 47.47 +Assert.assertTrue(arguments.length == 2); 47.48 +Assert.assertTrue(arguments[0] == "foo"); 47.49 +Assert.assertTrue(arguments[1] == "bar");
48.1 --- a/test/script/nosecurity/JDK-8050964.js Thu May 28 20:55:21 2015 -0700 48.2 +++ b/test/script/nosecurity/JDK-8050964.js Wed Jun 03 20:30:20 2015 -0700 48.3 @@ -47,7 +47,7 @@ 48.4 } 48.5 48.6 var javahome = System.getProperty("java.home"); 48.7 -var jdepsPath = javahome + "/../bin/jdeps".replaceAll(/\//g, File.separater); 48.8 +var jdepsPath = javahome + "/../bin/jdeps".replace(/\//g, File.separator); 48.9 48.10 // run jdep on nashorn.jar - only summary but print profile info 48.11 $ENV.PWD=System.getProperty("user.dir") // to avoid RE on Cygwin
49.1 --- a/test/script/nosecurity/JDK-8055034.js Thu May 28 20:55:21 2015 -0700 49.2 +++ b/test/script/nosecurity/JDK-8055034.js Wed Jun 03 20:30:20 2015 -0700 49.3 @@ -48,7 +48,7 @@ 49.4 // we want to use nashorn.jar passed and not the one that comes with JRE 49.5 var jjsCmd = javahome + "/../bin/jjs"; 49.6 jjsCmd += " -J-Djava.ext.dirs=" + nashornJarDir; 49.7 -jjsCmd = jjsCmd.toString().replaceAll(/\//g, File.separater); 49.8 +jjsCmd = jjsCmd.toString().replace(/\//g, File.separator); 49.9 $ENV.PWD=System.getProperty("user.dir") // to avoid RE on Cygwin 49.10 $EXEC(jjsCmd, "var x = Object.create(null);\nx;\nprint('PASSED');\nexit(0)"); 49.11
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/src/jdk/nashorn/internal/runtime/test/JDK_8078414_Test.java Wed Jun 03 20:30:20 2015 -0700 50.3 @@ -0,0 +1,99 @@ 50.4 +/* 50.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 50.7 + * 50.8 + * This code is free software; you can redistribute it and/or modify it 50.9 + * under the terms of the GNU General Public License version 2 only, as 50.10 + * published by the Free Software Foundation. Oracle designates this 50.11 + * particular file as subject to the "Classpath" exception as provided 50.12 + * by Oracle in the LICENSE file that accompanied this code. 50.13 + * 50.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.17 + * version 2 for more details (a copy is included in the LICENSE file that 50.18 + * accompanied this code). 50.19 + * 50.20 + * You should have received a copy of the GNU General Public License version 50.21 + * 2 along with this work; if not, write to the Free Software Foundation, 50.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.23 + * 50.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.25 + * or visit www.oracle.com if you need additional information or have any 50.26 + * questions. 50.27 + */ 50.28 + 50.29 +package jdk.nashorn.internal.runtime.test; 50.30 + 50.31 +import static org.testng.Assert.assertFalse; 50.32 +import static org.testng.Assert.assertTrue; 50.33 + 50.34 +import java.util.Map; 50.35 +import javax.script.Bindings; 50.36 +import jdk.nashorn.api.scripting.JSObject; 50.37 +import jdk.nashorn.api.scripting.ScriptObjectMirror; 50.38 +import jdk.nashorn.internal.objects.NativeArray; 50.39 +import jdk.nashorn.internal.runtime.ScriptObject; 50.40 +import jdk.nashorn.internal.runtime.linker.Bootstrap; 50.41 +import org.testng.annotations.Test; 50.42 + 50.43 +/** 50.44 + * @test 50.45 + * @bug 8078414 50.46 + * @summary Test that arbitrary classes can't be converted to mirror's superclasses/interfaces. 50.47 + * @run testng jdk.nashorn.internal.runtime.test.JDK_8078414_Test 50.48 + */ 50.49 +public class JDK_8078414_Test { 50.50 + @Test 50.51 + public void testCanNotConvertArbitraryClassToMirror() { 50.52 + assertCanNotConvert(Double.class, Map.class); 50.53 + assertCanNotConvert(Double.class, Bindings.class); 50.54 + assertCanNotConvert(Double.class, JSObject.class); 50.55 + assertCanNotConvert(Double.class, ScriptObjectMirror.class); 50.56 + } 50.57 + 50.58 + @Test 50.59 + public void testCanConvertObjectToMirror() { 50.60 + assertCanConvertToMirror(Object.class); 50.61 + } 50.62 + 50.63 + @Test 50.64 + public void testCanConvertScriptObjectToMirror() { 50.65 + assertCanConvertToMirror(ScriptObject.class); 50.66 + } 50.67 + 50.68 + @Test 50.69 + public void testCanConvertScriptObjectSubclassToMirror() { 50.70 + assertCanConvertToMirror(NativeArray.class); 50.71 + } 50.72 + 50.73 + @Test 50.74 + public void testCanConvertArbitraryInterfaceToMirror() { 50.75 + // We allow arbitrary interface classes, depending on what implements them, to end up being 50.76 + // convertible to ScriptObjectMirror, as an implementation can theoretically pass an 50.77 + // "instanceof ScriptObject" guard. 50.78 + assertCanConvertToMirror(TestInterface.class); 50.79 + } 50.80 + 50.81 + public static interface TestInterface { 50.82 + } 50.83 + 50.84 + private static boolean canConvert(final Class<?> from, final Class<?> to) { 50.85 + return Bootstrap.getLinkerServices().canConvert(from, to); 50.86 + } 50.87 + 50.88 + private static void assertCanConvert(final Class<?> from, final Class<?> to) { 50.89 + assertTrue(canConvert(from, to)); 50.90 + } 50.91 + 50.92 + private static void assertCanNotConvert(final Class<?> from, final Class<?> to) { 50.93 + assertFalse(canConvert(from, to)); 50.94 + } 50.95 + 50.96 + private static void assertCanConvertToMirror(final Class<?> from) { 50.97 + assertCanConvert(from, Map.class); 50.98 + assertCanConvert(from, Bindings.class); 50.99 + assertCanConvert(from, JSObject.class); 50.100 + assertCanConvert(from, ScriptObjectMirror.class); 50.101 + } 50.102 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/src/jdk/nashorn/internal/runtime/test/JDK_8081015_Test.java Wed Jun 03 20:30:20 2015 -0700 51.3 @@ -0,0 +1,74 @@ 51.4 +/* 51.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 + * 51.8 + * This code is free software; you can redistribute it and/or modify it 51.9 + * under the terms of the GNU General Public License version 2 only, as 51.10 + * published by the Free Software Foundation. Oracle designates this 51.11 + * particular file as subject to the "Classpath" exception as provided 51.12 + * by Oracle in the LICENSE file that accompanied this code. 51.13 + * 51.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.17 + * version 2 for more details (a copy is included in the LICENSE file that 51.18 + * accompanied this code). 51.19 + * 51.20 + * You should have received a copy of the GNU General Public License version 51.21 + * 2 along with this work; if not, write to the Free Software Foundation, 51.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.23 + * 51.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.25 + * or visit www.oracle.com if you need additional information or have any 51.26 + * questions. 51.27 + */ 51.28 + 51.29 +package jdk.nashorn.internal.runtime.test; 51.30 + 51.31 +import static org.testng.Assert.assertEquals; 51.32 +import static org.testng.Assert.assertNull; 51.33 + 51.34 +import java.util.Collection; 51.35 +import java.util.Queue; 51.36 +import javax.script.ScriptEngine; 51.37 +import javax.script.ScriptException; 51.38 +import jdk.nashorn.api.scripting.NashornScriptEngineFactory; 51.39 +import jdk.nashorn.test.models.JDK_8081015_TestModel; 51.40 +import org.testng.annotations.Test; 51.41 + 51.42 +/** 51.43 + * @bug 8081015 51.44 + * @summary Test that native arrays get converted to {@link Queue} and {@link Collection}. 51.45 + */ 51.46 +@SuppressWarnings("javadoc") 51.47 +public class JDK_8081015_Test { 51.48 + @Test 51.49 + public void testConvertToCollection() throws ScriptException { 51.50 + test("receiveCollection"); 51.51 + } 51.52 + 51.53 + @Test 51.54 + public void testConvertToDeque() throws ScriptException { 51.55 + test("receiveDeque"); 51.56 + } 51.57 + 51.58 + @Test 51.59 + public void testConvertToList() throws ScriptException { 51.60 + test("receiveList"); 51.61 + } 51.62 + 51.63 + @Test 51.64 + public void testConvertToQueue() throws ScriptException { 51.65 + test("receiveQueue"); 51.66 + } 51.67 + 51.68 + private static void test(final String methodName) throws ScriptException { 51.69 + final ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine(); 51.70 + final JDK_8081015_TestModel model = new JDK_8081015_TestModel(); 51.71 + engine.put("test", model); 51.72 + 51.73 + assertNull(model.getLastInvoked()); 51.74 + engine.eval("test." + methodName + "([1, 2, 3.3, 'foo'])"); 51.75 + assertEquals(model.getLastInvoked(), methodName ); 51.76 + } 51.77 +}
52.1 --- a/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Thu May 28 20:55:21 2015 -0700 52.2 +++ b/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Wed Jun 03 20:30:20 2015 -0700 52.3 @@ -22,7 +22,6 @@ 52.4 * or visit www.oracle.com if you need additional information or have any 52.5 * questions. 52.6 */ 52.7 - 52.8 package jdk.nashorn.internal.test.framework; 52.9 52.10 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_CHECK_COMPILE_MSG; 52.11 @@ -61,14 +60,15 @@ 52.12 import java.util.EnumSet; 52.13 import java.util.HashMap; 52.14 import java.util.HashSet; 52.15 +import java.util.Iterator; 52.16 import java.util.List; 52.17 import java.util.Map; 52.18 -import java.util.Scanner; 52.19 import java.util.Set; 52.20 import javax.xml.xpath.XPath; 52.21 import javax.xml.xpath.XPathConstants; 52.22 import javax.xml.xpath.XPathExpressionException; 52.23 import javax.xml.xpath.XPathFactory; 52.24 +import jdk.nashorn.internal.runtime.ScriptingFunctions; 52.25 import org.w3c.dom.NodeList; 52.26 import org.xml.sax.InputSource; 52.27 52.28 @@ -78,28 +78,33 @@ 52.29 */ 52.30 @SuppressWarnings("javadoc") 52.31 public final class TestFinder { 52.32 - private TestFinder() {} 52.33 + 52.34 + private TestFinder() { 52.35 + } 52.36 52.37 interface TestFactory<T> { 52.38 + 52.39 // 'test' instance type is decided by the client. 52.40 + 52.41 T createTest(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> arguments); 52.42 + 52.43 // place to log messages from TestFinder 52.44 + 52.45 void log(String mg); 52.46 } 52.47 52.48 - 52.49 // finds all tests from configuration and calls TestFactory to create 'test' instance for each script test found 52.50 static <T> void findAllTests(final List<T> tests, final Set<String> orphans, final TestFactory<T> testFactory) throws Exception { 52.51 final String framework = System.getProperty(TEST_JS_FRAMEWORK); 52.52 final String testList = System.getProperty(TEST_JS_LIST); 52.53 final String failedTestFileName = System.getProperty(TEST_FAILED_LIST_FILE); 52.54 - if(failedTestFileName != null) { 52.55 + if (failedTestFileName != null) { 52.56 final File failedTestFile = new File(failedTestFileName); 52.57 - if(failedTestFile.exists() && failedTestFile.length() > 0L) { 52.58 - try(final BufferedReader r = new BufferedReader(new FileReader(failedTestFile))) { 52.59 - for(;;) { 52.60 + if (failedTestFile.exists() && failedTestFile.length() > 0L) { 52.61 + try (final BufferedReader r = new BufferedReader(new FileReader(failedTestFile))) { 52.62 + for (;;) { 52.63 final String testFileName = r.readLine(); 52.64 - if(testFileName == null) { 52.65 + if (testFileName == null) { 52.66 break; 52.67 } 52.68 handleOneTest(framework, new File(testFileName).toPath(), tests, orphans, testFactory); 52.69 @@ -151,7 +156,7 @@ 52.70 final Exception[] exceptions = new Exception[1]; 52.71 final List<String> excludedActualTests = new ArrayList<>(); 52.72 52.73 - if (! dir.toFile().isDirectory()) { 52.74 + if (!dir.toFile().isDirectory()) { 52.75 factory.log("WARNING: " + dir + " not found or not a directory"); 52.76 } 52.77 52.78 @@ -219,27 +224,28 @@ 52.79 52.80 boolean explicitOptimistic = false; 52.81 52.82 - try (Scanner scanner = new Scanner(testFile)) { 52.83 - while (scanner.hasNext()) { 52.84 - // TODO: Scan for /ref=file qualifiers, etc, to determine run 52.85 - // behavior 52.86 - String token = scanner.next(); 52.87 - if (token.startsWith("/*")) { 52.88 - inComment = true; 52.89 - } else if (token.endsWith(("*/"))) { 52.90 - inComment = false; 52.91 - } else if (!inComment) { 52.92 - continue; 52.93 - } 52.94 + String allContent = new String(Files.readAllBytes(testFile)); 52.95 + Iterator<String> scanner = ScriptingFunctions.tokenizeCommandLine(allContent).iterator(); 52.96 + while (scanner.hasNext()) { 52.97 + // TODO: Scan for /ref=file qualifiers, etc, to determine run 52.98 + // behavior 52.99 + String token = scanner.next(); 52.100 + if (token.startsWith("/*")) { 52.101 + inComment = true; 52.102 + } else if (token.endsWith(("*/"))) { 52.103 + inComment = false; 52.104 + } else if (!inComment) { 52.105 + continue; 52.106 + } 52.107 52.108 - // remove whitespace and trailing semicolons, if any 52.109 - // (trailing semicolons are found in some sputnik tests) 52.110 - token = token.trim(); 52.111 - final int semicolon = token.indexOf(';'); 52.112 - if (semicolon > 0) { 52.113 - token = token.substring(0, semicolon); 52.114 - } 52.115 - switch (token) { 52.116 + // remove whitespace and trailing semicolons, if any 52.117 + // (trailing semicolons are found in some sputnik tests) 52.118 + token = token.trim(); 52.119 + final int semicolon = token.indexOf(';'); 52.120 + if (semicolon > 0) { 52.121 + token = token.substring(0, semicolon); 52.122 + } 52.123 + switch (token) { 52.124 case "@test": 52.125 isTest = true; 52.126 break; 52.127 @@ -308,24 +314,21 @@ 52.128 break; 52.129 default: 52.130 break; 52.131 - } 52.132 + } 52.133 52.134 - // negative tests are expected to fail at runtime only 52.135 - // for those tests that are expected to fail at compile time, 52.136 - // add @test/compile-error 52.137 - if (token.equals("@negative") || token.equals("@strict_mode_negative")) { 52.138 - shouldRun = true; 52.139 - runFailure = true; 52.140 - } 52.141 + // negative tests are expected to fail at runtime only 52.142 + // for those tests that are expected to fail at compile time, 52.143 + // add @test/compile-error 52.144 + if (token.equals("@negative") || token.equals("@strict_mode_negative")) { 52.145 + shouldRun = true; 52.146 + runFailure = true; 52.147 + } 52.148 52.149 - if (token.equals("@strict_mode") || token.equals("@strict_mode_negative") || token.equals("@onlyStrict") || token.equals("@noStrict")) { 52.150 - if (!strictModeEnabled()) { 52.151 - return; 52.152 - } 52.153 + if (token.equals("@strict_mode") || token.equals("@strict_mode_negative") || token.equals("@onlyStrict") || token.equals("@noStrict")) { 52.154 + if (!strictModeEnabled()) { 52.155 + return; 52.156 } 52.157 } 52.158 - } catch (final Exception ignored) { 52.159 - return; 52.160 } 52.161 52.162 if (isTest) { 52.163 @@ -369,8 +372,8 @@ 52.164 private static final boolean OPTIMISTIC_OVERRIDE = true; 52.165 52.166 /** 52.167 - * Check if there is an optimistic override, that disables the default 52.168 - * false optimistic types and sets them to true, for testing purposes 52.169 + * Check if there is an optimistic override, that disables the default false 52.170 + * optimistic types and sets them to true, for testing purposes 52.171 * 52.172 * @return true if optimistic type override has been set by test suite 52.173 */ 52.174 @@ -379,10 +382,9 @@ 52.175 } 52.176 52.177 /** 52.178 - * Add an optimistic-types=true option to an argument list if this 52.179 - * is set to override the default false. Add an optimistic-types=true 52.180 - * options to an argument list if this is set to override the default 52.181 - * true 52.182 + * Add an optimistic-types=true option to an argument list if this is set to 52.183 + * override the default false. Add an optimistic-types=true options to an 52.184 + * argument list if this is set to override the default true 52.185 * 52.186 * @args new argument list array 52.187 */ 52.188 @@ -396,8 +398,8 @@ 52.189 } 52.190 52.191 /** 52.192 - * Add an optimistic-types=true option to an argument list if this 52.193 - * is set to override the default false 52.194 + * Add an optimistic-types=true option to an argument list if this is set to 52.195 + * override the default false 52.196 * 52.197 * @args argument list 52.198 */ 52.199 @@ -438,7 +440,7 @@ 52.200 52.201 private static void loadExcludesFile(final String testExcludesFile, final Set<String> testExcludeSet) throws XPathExpressionException { 52.202 final XPath xpath = XPathFactory.newInstance().newXPath(); 52.203 - final NodeList testIds = (NodeList)xpath.evaluate("/excludeList/test/@id", new InputSource(testExcludesFile), XPathConstants.NODESET); 52.204 + final NodeList testIds = (NodeList) xpath.evaluate("/excludeList/test/@id", new InputSource(testExcludesFile), XPathConstants.NODESET); 52.205 for (int i = testIds.getLength() - 1; i >= 0; i--) { 52.206 testExcludeSet.add(testIds.item(i).getNodeValue()); 52.207 }
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/test/src/jdk/nashorn/test/models/JDK_8081015_TestModel.java Wed Jun 03 20:30:20 2015 -0700 53.3 @@ -0,0 +1,73 @@ 53.4 +/* 53.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 53.7 + * 53.8 + * This code is free software; you can redistribute it and/or modify it 53.9 + * under the terms of the GNU General Public License version 2 only, as 53.10 + * published by the Free Software Foundation. Oracle designates this 53.11 + * particular file as subject to the "Classpath" exception as provided 53.12 + * by Oracle in the LICENSE file that accompanied this code. 53.13 + * 53.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 53.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 53.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 53.17 + * version 2 for more details (a copy is included in the LICENSE file that 53.18 + * accompanied this code). 53.19 + * 53.20 + * You should have received a copy of the GNU General Public License version 53.21 + * 2 along with this work; if not, write to the Free Software Foundation, 53.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 53.23 + * 53.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 53.25 + * or visit www.oracle.com if you need additional information or have any 53.26 + * questions. 53.27 + */ 53.28 + 53.29 +package jdk.nashorn.test.models; 53.30 + 53.31 +import static org.testng.Assert.assertEquals; 53.32 +import static org.testng.Assert.assertFalse; 53.33 + 53.34 +import java.util.Collection; 53.35 +import java.util.Deque; 53.36 +import java.util.Iterator; 53.37 +import java.util.List; 53.38 +import java.util.Queue; 53.39 + 53.40 +@SuppressWarnings("javadoc") 53.41 +public class JDK_8081015_TestModel { 53.42 + private String lastInvoked; 53.43 + 53.44 + public void receiveCollection(final Collection<Object> c) { 53.45 + lastInvoked = "receiveCollection"; 53.46 + walkCollection(c); 53.47 + } 53.48 + 53.49 + public void receiveDeque(final Deque<Object> d) { 53.50 + lastInvoked = "receiveDeque"; 53.51 + walkCollection(d); 53.52 + } 53.53 + 53.54 + public void receiveList(final List<Object> l) { 53.55 + lastInvoked = "receiveList"; 53.56 + walkCollection(l); 53.57 + } 53.58 + 53.59 + public void receiveQueue(final Queue<Object> q) { 53.60 + lastInvoked = "receiveQueue"; 53.61 + walkCollection(q); 53.62 + } 53.63 + 53.64 + public String getLastInvoked() { 53.65 + return lastInvoked; 53.66 + } 53.67 + 53.68 + private static void walkCollection(final Collection<Object> c) { 53.69 + final Iterator<Object> it = c.iterator(); 53.70 + assertEquals(it.next(), Integer.valueOf(1)); 53.71 + assertEquals(it.next(), Integer.valueOf(2)); 53.72 + assertEquals(it.next(), Double.valueOf(3.3)); 53.73 + assertEquals(it.next(), "foo"); 53.74 + assertFalse(it.hasNext()); 53.75 + } 53.76 +}