diff --git a/nashorn/docs/genshelldoc.js b/nashorn/docs/genshelldoc.js index 3d11a471a3e..964735129a5 100644 --- a/nashorn/docs/genshelldoc.js +++ b/nashorn/docs/genshelldoc.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. - * + * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). - * + * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * + * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. @@ -61,7 +61,7 @@ PREFIX); for each (opt in Options.validOptions) { -var isTimezone = (opt.type == "timezone"); +var isTimezone = (opt.type == "timezone"); var defValue = opt.defaultValue; if (defValue == null) { defValue = "<none>"; diff --git a/nashorn/docs/source/importpackageclass.js b/nashorn/docs/source/importpackageclass.js index afc02a9bf37..224debd6e4a 100644 --- a/nashorn/docs/source/importpackageclass.js +++ b/nashorn/docs/source/importpackageclass.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -32,7 +32,7 @@ // load compatibility script load("nashorn:mozilla_compat.js"); -// Import Java packages and classes +// Import Java packages and classes // like import package.*; in Java importPackage(java.awt); // like import java.awt.Frame in Java diff --git a/nashorn/docs/source/javaarray.js b/nashorn/docs/source/javaarray.js index d0de9124684..659619107fc 100644 --- a/nashorn/docs/source/javaarray.js +++ b/nashorn/docs/source/javaarray.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/docs/source/javaextend.js b/nashorn/docs/source/javaextend.js index 408da320a19..f1c6256b012 100644 --- a/nashorn/docs/source/javaextend.js +++ b/nashorn/docs/source/javaextend.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/docs/source/javaimporter.js b/nashorn/docs/source/javaimporter.js index 3bd07988d21..5004ce889d1 100644 --- a/nashorn/docs/source/javaimporter.js +++ b/nashorn/docs/source/javaimporter.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/docs/source/javatypes.js b/nashorn/docs/source/javatypes.js index e0b6f07b137..82392ec4495 100644 --- a/nashorn/docs/source/javatypes.js +++ b/nashorn/docs/source/javatypes.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/docs/source/overload.js b/nashorn/docs/source/overload.js index 2407d0c5a5c..a2905f94d3c 100644 --- a/nashorn/docs/source/overload.js +++ b/nashorn/docs/source/overload.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -31,6 +31,6 @@ var out = java.lang.System.out; -// select a particular print function +// select a particular print function out["println(java.lang.Object)"]("hello"); diff --git a/nashorn/docs/source/runnable.js b/nashorn/docs/source/runnable.js index 67cd31c67cf..346c2522a36 100644 --- a/nashorn/docs/source/runnable.js +++ b/nashorn/docs/source/runnable.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/docs/source/samfunc.js b/nashorn/docs/source/samfunc.js index c870076e1fd..dbb321d0f55 100644 --- a/nashorn/docs/source/samfunc.js +++ b/nashorn/docs/source/samfunc.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/docs/source/test.js b/nashorn/docs/source/test.js index 6323c386479..56e96ef26ad 100644 --- a/nashorn/docs/source/test.js +++ b/nashorn/docs/source/test.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 35edc417edb..92d6f5dd16f 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -519,6 +519,8 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { + + @@ -582,6 +584,8 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { + + diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index 642793a8e66..800a62956da 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -202,7 +202,7 @@ test262-test-sys-prop.test.js.enable.strict.mode=true # list of test262 test dirs to be excluded test262-test-sys-prop.test.js.exclude.dir=\ ${test262.suite.dir}/intl402/ \ - ${test262.suite.dir}/bestPractice/ + ${test262.suite.dir}/bestPractice/ test262-test-sys-prop.test.failed.list.file=${build.dir}/test/failedTests @@ -217,7 +217,7 @@ test262-test-sys-prop.test.js.framework=\ ${test262.dir}/test/harness/sta.js # testmarkdown test root -testmarkdown-test-sys-prop.test.js.roots=${testmarkdown.dir} +testmarkdown-test-sys-prop.test.js.roots=${testmarkdown.dir} # execute testmarkdown tests in shared nashorn context or not? testmarkdown-test-sys-prop.test.js.shared.context=false @@ -227,7 +227,7 @@ testmarkdown-test-sys-prop.test.js.framework=\ ${test.script.dir}${file.separator}markdown.js # testjfx test root -testjfx-test-sys-prop.test.js.roots=${testjfx.dir} +testjfx-test-sys-prop.test.js.roots=${testjfx.dir} # execute testjfx tests in shared nashorn context or not? testjfx-test-sys-prop.test.js.shared.context=false diff --git a/nashorn/samples/array_mapreduce.js b/nashorn/samples/array_mapreduce.js index 5335f35dddf..32184e9c71d 100644 --- a/nashorn/samples/array_mapreduce.js +++ b/nashorn/samples/array_mapreduce.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -31,9 +31,9 @@ // Usage: jjs array_mapreduce.js -// Many Array.prototype functions such as map, +// Many Array.prototype functions such as map, // filter, reduce, reduceRight, every, some are generic. -// These functions accept ECMAScript array as well as +// These functions accept ECMAScript array as well as // many array-like objects including java arrays. // So, you can do map/filter/reduce with Java streams or // you can also use Array.prototype functions as below. @@ -73,6 +73,6 @@ forEach.call(jarr, function(x) print(x)); // print sum of squares of the random numbers print("Square sum:", reduce.call( - map.call(jarr, function(x) x*x), + map.call(jarr, function(x) x*x), function(x, y) x + y) ); diff --git a/nashorn/samples/astviewer.js b/nashorn/samples/astviewer.js index 090e50eed11..ad70d91d395 100644 --- a/nashorn/samples/astviewer.js +++ b/nashorn/samples/astviewer.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -82,7 +82,7 @@ var sourceName = arguments.length == 0? __FILE__ : arguments[0]; // load parser.js from nashorn resources load("nashorn:parser.js"); -// read the full content of the file and parse it +// read the full content of the file and parse it // to get AST of the script specified var ast = parse(readFully(sourceName)); diff --git a/nashorn/samples/barchart_weather.js b/nashorn/samples/barchart_weather.js index 8574f0a2341..9402682f176 100644 --- a/nashorn/samples/barchart_weather.js +++ b/nashorn/samples/barchart_weather.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/call_lambda.js b/nashorn/samples/call_lambda.js index d865164f8b8..c5a4dc665c8 100644 --- a/nashorn/samples/call_lambda.js +++ b/nashorn/samples/call_lambda.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/counters.js b/nashorn/samples/counters.js index d89ad581cc2..4a570b02480 100644 --- a/nashorn/samples/counters.js +++ b/nashorn/samples/counters.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/dirname.js b/nashorn/samples/dirname.js index 119d4f33624..bb9279d0154 100644 --- a/nashorn/samples/dirname.js +++ b/nashorn/samples/dirname.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/disassemble.js b/nashorn/samples/disassemble.js index 654b9dd8d0e..7cf501ffab5 100644 --- a/nashorn/samples/disassemble.js +++ b/nashorn/samples/disassemble.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -33,7 +33,7 @@ // Simple .class disassembler that uses bundled ObjectWeb ASM // classes in jdk8. WARNING: Bundled ObjectWeb ASM classes are -// not part of official jdk8 API. It can be changed/removed +// not part of official jdk8 API. It can be changed/removed // without notice. So, this script is brittle by design! // This example demonstrates passing arguments to script diff --git a/nashorn/samples/engine/accessvar.js b/nashorn/samples/engine/accessvar.js index ae9ec7de625..abd5486219a 100644 --- a/nashorn/samples/engine/accessvar.js +++ b/nashorn/samples/engine/accessvar.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/engine/callfunc.js b/nashorn/samples/engine/callfunc.js index 76108fd15ee..e177a7b9258 100644 --- a/nashorn/samples/engine/callfunc.js +++ b/nashorn/samples/engine/callfunc.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -29,7 +29,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// simple example showing how to call a global script +// simple example showing how to call a global script // function from caller var ScriptEngineManager = Java.type("javax.script.ScriptEngineManager"); @@ -42,7 +42,7 @@ var engine = manager.getEngineByName("js"); engine.eval("function func(name) { print('I am func, hello ' + name) }"); // invoke functions, methods of code evaluated by engine -// from javax.script.Invocable interface. But, hey, +// from javax.script.Invocable interface. But, hey, // calling code is JavaScript and don't worry about types :) engine.invokeFunction("func", "Nashorn"); diff --git a/nashorn/samples/engine/callmethod.js b/nashorn/samples/engine/callmethod.js index 8199dcd6c69..c8cbb300d4a 100644 --- a/nashorn/samples/engine/callmethod.js +++ b/nashorn/samples/engine/callmethod.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -55,7 +55,7 @@ engine.eval(<"); exit(1); } - + // Java types used var File = Java.type("java.io.File"); var Files = Java.type("java.nio.file.Files"); @@ -48,7 +48,7 @@ var ToolProvider = Java.type("javax.tools.ToolProvider"); var Tree = Java.type("com.sun.source.tree.Tree"); var TreeScanner = Java.type("com.sun.source.util.TreeScanner"); var VariableTree = Java.type("com.sun.source.tree.VariableTree"); - + // count "foo"-s in the given .java files function countFoo() { // get the system compiler tool @@ -63,7 +63,7 @@ function countFoo() { // subclass SimpleTreeVisitor - to count variables called "foo" var FooCounterVisitor = Java.extend(TreeScanner); var fooCount = 0; - + var visitor = new FooCounterVisitor() { visitVariable: function (node, p) { if (node.name.toString() == "foo") { @@ -71,13 +71,13 @@ function countFoo() { } } } - + for each (var cu in task.parse()) { cu.accept(visitor, null); } return fooCount; } - + // for each ".java" file in directory (recursively) count "foo". function main(dir) { var totalCount = 0; @@ -99,5 +99,5 @@ function main(dir) { }); print("Total foo count: " + totalCount); } - + main(new File(arguments[0])); diff --git a/nashorn/samples/javaimporter.js b/nashorn/samples/javaimporter.js index dd487ec105a..3e3cb1ba666 100644 --- a/nashorn/samples/javaimporter.js +++ b/nashorn/samples/javaimporter.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -34,14 +34,14 @@ function readTextFromURL(url) { - // equivalent to - // + // equivalent to + // // import java.io.*; // import java.net.*; // import java.lang.StringBuffer; // // only inside the 'with' statement - with (new JavaImporter(java.io, + with (new JavaImporter(java.io, java.net, java.lang.StringBuilder)) { var buf = new StringBuilder(); diff --git a/nashorn/samples/javalist.js b/nashorn/samples/javalist.js index 8f3749b5005..5430dbdedbe 100644 --- a/nashorn/samples/javalist.js +++ b/nashorn/samples/javalist.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/javamap.js b/nashorn/samples/javamap.js index a53d032046a..57da6203306 100644 --- a/nashorn/samples/javamap.js +++ b/nashorn/samples/javamap.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -45,7 +45,7 @@ print(map.get('js')); print(map['js']); print(map.js); -// also assign new key-value pair +// also assign new key-value pair // as 'property-value' map['language'] = 'java'; print(map.get("language")); diff --git a/nashorn/samples/javashell.js b/nashorn/samples/javashell.js index 65d1a8a261d..4e71f753914 100644 --- a/nashorn/samples/javashell.js +++ b/nashorn/samples/javashell.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -130,7 +130,7 @@ function exec(args) { // generate unique name function uniqueName() { var now = LocalDateTime.now().toString(); - // replace unsafe chars with '_' + // replace unsafe chars with '_' return "JavaShell" + now.replace(/-|:|\./g, '_'); } diff --git a/nashorn/samples/jsadapter_dom.js b/nashorn/samples/jsadapter_dom.js index e86c6d2f54c..cb2f8baa6dc 100644 --- a/nashorn/samples/jsadapter_dom.js +++ b/nashorn/samples/jsadapter_dom.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -33,7 +33,7 @@ // Simple example that demonstrates reading XML Rss feed // to generate a HTML file from script and show it by browser -// Uses XML DOM parser and DOM element wrapped by script +// Uses XML DOM parser and DOM element wrapped by script // "proxy" (JSAdapter constructor) // Java classes used @@ -78,7 +78,7 @@ function getElemText(elem) { var node = nodeList.item(i); if (node.nodeType == TEXT_NODE) { text += node.nodeValue; - } + } } return text; diff --git a/nashorn/samples/jsobj_example.js b/nashorn/samples/jsobj_example.js index eff66966af9..d608876e995 100644 --- a/nashorn/samples/jsobj_example.js +++ b/nashorn/samples/jsobj_example.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -33,7 +33,7 @@ var AbstractJSObject = Java.type("jdk.nashorn.api.scripting.AbstractJSObject"); -// JSObject example that uses a map for properties and +// JSObject example that uses a map for properties and // falls back to with methods on a java object (for missing // properties @@ -49,7 +49,7 @@ function makeJSObj(map, fallback) { return function() { var a = arguments; switch (a.length) { - case 0: return fallback[name](); + case 0: return fallback[name](); case 1: return fallback[name](a[0]); case 2: return fallback[name](a[0], a[1]); case 3: return fallback[name](a[0], a[1], a[2]); diff --git a/nashorn/samples/jsobject.js b/nashorn/samples/jsobject.js index 48434d7d84e..ad09b2f103f 100644 --- a/nashorn/samples/jsobject.js +++ b/nashorn/samples/jsobject.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/jsobject_mapreduce.js b/nashorn/samples/jsobject_mapreduce.js index ff34940be9e..174ad0a97dd 100644 --- a/nashorn/samples/jsobject_mapreduce.js +++ b/nashorn/samples/jsobject_mapreduce.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -31,9 +31,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// Many Array.prototype functions such as map, +// Many Array.prototype functions such as map, // filter, reduce, reduceRight, every, some are generic. -// These functions accept ECMAScript array as well as +// These functions accept ECMAScript array as well as // many array-like objects including JSObjects. // See also http://en.wikipedia.org/wiki/MapReduce @@ -57,6 +57,6 @@ forEach.call(buf, function(x) print(x)); // print sum of squares of the random numbers print("Square sum:", reduce.call( - map.call(buf, function(x) x*x), + map.call(buf, function(x) x*x), function(x, y) x + y) ); diff --git a/nashorn/samples/jsonviewer.js b/nashorn/samples/jsonviewer.js index 804fef50bc4..c650ae98af2 100644 --- a/nashorn/samples/jsonviewer.js +++ b/nashorn/samples/jsonviewer.js @@ -4,22 +4,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -52,8 +52,8 @@ var TreeView = Java.type("javafx.scene.control.TreeView"); // read text content of a URL function readTextFromURL(url) { - // equivalent to - // + // equivalent to + // // import java.io.*; // import java.net.*; // import java.lang.StringBuffer; diff --git a/nashorn/samples/letter.js b/nashorn/samples/letter.js index 304bf1fbbb2..b5a58b89879 100644 --- a/nashorn/samples/letter.js +++ b/nashorn/samples/letter.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -43,7 +43,7 @@ var obj = { sender: $ARG[0], recipient: $ARG[1] }; // JavaScript style line comment is ok too. print(< (stack.js:52) +// at g (stack.js:37) +// at f (stack.js:41) +// at (stack.js:52) try { f(); diff --git a/nashorn/samples/uniform_random.js b/nashorn/samples/uniform_random.js index a82cd0bba37..da3f26af695 100644 --- a/nashorn/samples/uniform_random.js +++ b/nashorn/samples/uniform_random.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/uniq.js b/nashorn/samples/uniq.js index cbd2c34d062..f9316eb4bcb 100644 --- a/nashorn/samples/uniq.js +++ b/nashorn/samples/uniq.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/uniqs.js b/nashorn/samples/uniqs.js index 57eb7c52f32..1c36c676a52 100644 --- a/nashorn/samples/uniqs.js +++ b/nashorn/samples/uniqs.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -31,7 +31,7 @@ // Usage: jjs uniqs.js -- // omit repeated lines and print unique lines -// But this version uses Stream API +// But this version uses Stream API if (arguments.length < 1) { print("Usage: jjs uniqs.js -- "); diff --git a/nashorn/samples/weather.js b/nashorn/samples/weather.js index 75c6b265a0e..3a37bc1da3e 100644 --- a/nashorn/samples/weather.js +++ b/nashorn/samples/weather.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/word_histogram.js b/nashorn/samples/word_histogram.js index 9c739ea0375..39f4f6863c8 100644 --- a/nashorn/samples/word_histogram.js +++ b/nashorn/samples/word_histogram.js @@ -2,22 +2,22 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/nashorn/samples/zipfs.js b/nashorn/samples/zipfs.js new file mode 100644 index 00000000000..ecb6f61a54b --- /dev/null +++ b/nashorn/samples/zipfs.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +if (arguments.length == 0) { + print("Usage: jjs zipfs.js -- <.zip/.jar file>") + exit(1) +} + +var Files = Java.type("java.nio.file.Files") +var FileSystems = Java.type("java.nio.file.FileSystems") +var FileVisitOption = Java.type("java.nio.file.FileVisitOption") +var Paths = Java.type("java.nio.file.Paths") + +var zipfile = Paths.get(arguments[0]) +var fs = FileSystems.newFileSystem(zipfile, null) +var root = fs.rootDirectories[0] +Files.walk(root, FileVisitOption.FOLLOW_LINKS).forEach( + function(p) (print(p), print(Files.readAttributes(p, "zip:*"))) +) +fs.close() diff --git a/nashorn/samples/ziplist.js b/nashorn/samples/ziplist.js index 6de35f4783e..214dd35104a 100644 --- a/nashorn/samples/ziplist.js +++ b/nashorn/samples/ziplist.js @@ -1,21 +1,21 @@ /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -30,7 +30,7 @@ */ if (arguments.length == 0) { - print("Usage: jjs ziplist "); + print("Usage: jjs ziplist -- "); exit(1); } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngine.java index abdb79c287c..ce2b83aecff 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngine.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngine.java @@ -40,7 +40,6 @@ import java.security.ProtectionDomain; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; - import javax.script.AbstractScriptEngine; import javax.script.Bindings; import javax.script.Compilable; @@ -51,7 +50,6 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptException; import javax.script.SimpleBindings; - import jdk.nashorn.internal.objects.Global; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ErrorManager; diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java index 8763c22f466..b261a1b629e 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java @@ -715,6 +715,23 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin return newArgs; } + /** + * Are the given objects mirrors to same underlying object? + * + * @param obj1 first object + * @param obj2 second object + * @return true if obj1 and obj2 are identical script objects or mirrors of it. + */ + public static boolean identical(final Object obj1, final Object obj2) { + final Object o1 = (obj1 instanceof ScriptObjectMirror)? + ((ScriptObjectMirror)obj1).sobj : obj1; + + final Object o2 = (obj2 instanceof ScriptObjectMirror)? + ((ScriptObjectMirror)obj2).sobj : obj2; + + return o1 == o2; + } + // package-privates below this. ScriptObjectMirror(final ScriptObject sobj, final Global global) { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AssignSymbols.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AssignSymbols.java index 0659e3f5c3e..91a022d9acc 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AssignSymbols.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AssignSymbols.java @@ -382,10 +382,6 @@ final class AssignSymbols extends NodeOperatorVisitor implements symbol.setFlags(flags); } - if((isVar || isParam) && compiler.useOptimisticTypes() && compiler.isOnDemandCompilation()) { - compiler.declareLocalSymbol(name); - } - return symbol; } @@ -687,6 +683,22 @@ final class AssignSymbols extends NodeOperatorVisitor implements return binaryNode; } + @Override + public Node leaveBlock(final Block block) { + // It's not necessary to guard the marking of symbols as locals with this "if"condition for correctness, it's + // just an optimization -- runtime type calculation is not used when the compilation is not an on-demand + // optimistic compilation, so we can skip locals marking then. + if (compiler.useOptimisticTypes() && compiler.isOnDemandCompilation()) { + for (final Symbol symbol: block.getSymbols()) { + if (!symbol.isScope()) { + assert symbol.isVar() || symbol.isParam(); + compiler.declareLocalSymbol(symbol.getName()); + } + } + } + return block; + } + @Override public Node leaveDELETE(final UnaryNode unaryNode) { final FunctionNode currentFunctionNode = lc.getCurrentFunction(); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java index 5b7bf91ab2a..0266e5d1ae4 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -56,7 +56,6 @@ import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALL import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_OPTIMISTIC; import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_PROGRAM_POINT_SHIFT; import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_SCOPE; -import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_STRICT; import java.io.PrintWriter; import java.util.ArrayDeque; @@ -250,8 +249,6 @@ final class CodeGenerator extends NodeOperatorVisitor scopeEntryLabels = new ArrayDeque<>(); - private final Set initializedFunctionIds = new HashSet<>(); - private static final Label METHOD_BOUNDARY = new Label(""); private final Deque