Fri, 30 May 2014 17:22:38 +0530
8044415: ant makefile should have a target to generate javadoc only for jdk.nashorn.api and sub-packages
Reviewed-by: jlaskey
1.1 --- a/make/build.xml Wed May 28 11:08:07 2014 -0700 1.2 +++ b/make/build.xml Fri May 30 17:22:38 2014 +0530 1.3 @@ -193,14 +193,16 @@ 1.4 </jar> 1.5 </target> 1.6 1.7 - <target name="javadoc" depends="prepare"> 1.8 - <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="src/overview.html" windowtitle="${nashorn.product.name} ${nashorn.version}" additionalparam="-quiet" failonerror="true"> 1.9 + <target name="javadoc" depends="jar"> 1.10 + <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="src/overview.html" 1.11 + extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}" 1.12 + additionalparam="-quiet" failonerror="true"> 1.13 <classpath> 1.14 <pathelement location="${build.classes.dir}"/> 1.15 </classpath> 1.16 <fileset dir="${src.dir}" includes="**/*.java"/> 1.17 <fileset dir="${jdk.asm.src.dir}" includes="**/*.java"/> 1.18 - <link href="http://docs.oracle.com/javase/7/docs/api/"/> 1.19 + <link href="http://docs.oracle.com/javase/8/docs/api/"/> 1.20 <!-- The following tags are used only in ASM sources - just ignore these --> 1.21 <tag name="label" description="label tag in ASM sources" enabled="false"/> 1.22 <tag name="linked" description="linked tag in ASM sources" enabled="false"/> 1.23 @@ -208,6 +210,19 @@ 1.24 </javadoc> 1.25 </target> 1.26 1.27 + <!-- generate javadoc only for nashorn extension api classes --> 1.28 + <target name="javadocapi" depends="jar"> 1.29 + <javadoc destdir="${dist.javadoc.dir}" use="yes" extdirs="${nashorn.ext.path}" 1.30 + windowtitle="${nashorn.product.name}" additionalparam="-quiet" failonerror="true"> 1.31 + <classpath> 1.32 + <pathelement location="${build.classes.dir}"/> 1.33 + </classpath> 1.34 + <fileset dir="${src.dir}" includes="jdk/nashorn/api/**/*.java"/> 1.35 + <link href="http://docs.oracle.com/javase/8/docs/api/"/> 1.36 + </javadoc> 1.37 + </target> 1.38 + 1.39 + 1.40 <!-- generate shell.html for shell tool documentation --> 1.41 <target name="shelldoc" depends="jar"> 1.42 <java classname="${nashorn.shell.tool}" dir="${basedir}" output="${dist.dir}/shell.html" failonerror="true" fork="true">
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/samples/filebrowser.js Fri May 30 17:22:38 2014 +0530 2.3 @@ -0,0 +1,100 @@ 2.4 +#// Usage: jjs -fx filebrowser.js -- <start_dir> 2.5 + 2.6 +/* 2.7 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2.8 + * 2.9 + * Redistribution and use in source and binary forms, with or without 2.10 + * modification, are permitted provided that the following conditions 2.11 + * are met: 2.12 + * 2.13 + * - Redistributions of source code must retain the above copyright 2.14 + * notice, this list of conditions and the following disclaimer. 2.15 + * 2.16 + * - Redistributions in binary form must reproduce the above copyright 2.17 + * notice, this list of conditions and the following disclaimer in the 2.18 + * documentation and/or other materials provided with the distribution. 2.19 + * 2.20 + * - Neither the name of Oracle nor the names of its 2.21 + * contributors may be used to endorse or promote products derived 2.22 + * from this software without specific prior written permission. 2.23 + * 2.24 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 2.25 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 2.26 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2.27 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 2.28 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2.29 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2.30 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2.31 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 2.32 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 2.33 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 2.34 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2.35 + */ 2.36 + 2.37 +// Uses -fx and javafx TreeView to visualize directories 2.38 +if (!$OPTIONS._fx) { 2.39 + print("Usage: jjs -fx filebrowser.js -- <start_dir>"); 2.40 + exit(1); 2.41 +} 2.42 + 2.43 +// Java classes used 2.44 +var File = Java.type("java.io.File"); 2.45 +var Files = Java.type("java.nio.file.Files"); 2.46 + 2.47 +// check directory argument, if passed 2.48 +var dir = arguments.length > 0? new File(arguments[0]) : new File("."); 2.49 +if (! dir.isDirectory()) { 2.50 + print(dir + " is not a directory!"); 2.51 + exit(2); 2.52 +} 2.53 + 2.54 +// JavaFX classes used 2.55 +var FXCollections = Java.type("javafx.collections.FXCollections"); 2.56 +var Scene = Java.type("javafx.scene.Scene"); 2.57 +var TreeItem = Java.type("javafx.scene.control.TreeItem"); 2.58 +var TreeView = Java.type("javafx.scene.control.TreeView"); 2.59 + 2.60 +// create a subclass of JavaFX TreeItem class 2.61 +var LazyTreeItem = Java.extend(TreeItem); 2.62 + 2.63 +// lazily filling children of a directory LazyTreeItem 2.64 +function buildChildren(dir) { 2.65 + var children = FXCollections.observableArrayList(); 2.66 + var stream = Files.list(dir.toPath()); 2.67 + stream.forEach(function(path) { 2.68 + var file = path.toFile(); 2.69 + var item = file.isDirectory()? 2.70 + makeLazyTreeItem(file) : new TreeItem(file.name); 2.71 + children.add(item); 2.72 + }); 2.73 + stream.close(); 2.74 + return children; 2.75 +} 2.76 + 2.77 +// create an instance LazyTreeItem with override methods 2.78 +function makeLazyTreeItem(dir) { 2.79 + var item = new LazyTreeItem(dir.name) { 2.80 + expanded: false, 2.81 + isLeaf: function() false, 2.82 + getChildren: function() { 2.83 + if (! this.expanded) { 2.84 + // call super class (TreeItem) method 2.85 + Java.super(item).getChildren().setAll(buildChildren(dir)); 2.86 + this.expanded = true; 2.87 + } 2.88 + // call super class (TreeItem) method 2.89 + return Java.super(item).getChildren(); 2.90 + } 2.91 + } 2.92 + return item; 2.93 +} 2.94 + 2.95 +// JavaFX start method 2.96 +function start(stage) { 2.97 + stage.title = dir.absolutePath; 2.98 + var rootItem = makeLazyTreeItem(dir); 2.99 + rootItem.expanded = true; 2.100 + var tree = new TreeView(rootItem); 2.101 + stage.scene = new Scene(tree, 300, 450); 2.102 + stage.show(); 2.103 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/samples/word_histogram.js Fri May 30 17:22:38 2014 +0530 3.3 @@ -0,0 +1,53 @@ 3.4 +#nashorn word histogram of a file 3.5 + 3.6 +/* 3.7 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3.8 + * 3.9 + * Redistribution and use in source and binary forms, with or without 3.10 + * modification, are permitted provided that the following conditions 3.11 + * are met: 3.12 + * 3.13 + * - Redistributions of source code must retain the above copyright 3.14 + * notice, this list of conditions and the following disclaimer. 3.15 + * 3.16 + * - Redistributions in binary form must reproduce the above copyright 3.17 + * notice, this list of conditions and the following disclaimer in the 3.18 + * documentation and/or other materials provided with the distribution. 3.19 + * 3.20 + * - Neither the name of Oracle nor the names of its 3.21 + * contributors may be used to endorse or promote products derived 3.22 + * from this software without specific prior written permission. 3.23 + * 3.24 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 3.25 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 3.26 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 3.27 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 3.28 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 3.29 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 3.30 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 3.31 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 3.32 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 3.33 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3.34 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3.35 + */ 3.36 + 3.37 +/* 3.38 + * This example demonstrates how to print word histogram 3.39 + * of a given text file using regex, array and JSON 3.40 + * functions. 3.41 + */ 3.42 + 3.43 +if (arguments.length < 1) { 3.44 + print("Usage: jjs -scripting word_histogram.js -- <file>"); 3.45 + exit(1); 3.46 +} 3.47 + 3.48 +var obj = {}; 3.49 + 3.50 +readFully(arguments[0]). 3.51 + split(/[^\w+]/). 3.52 + forEach(function(x) 3.53 + (x in obj? obj[x]++ : obj[x] = 1)); 3.54 + 3.55 +print(JSON.stringify(obj)); 3.56 +
4.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Wed May 28 11:08:07 2014 -0700 4.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Fri May 30 17:22:38 2014 +0530 4.3 @@ -621,6 +621,7 @@ 4.4 /** 4.5 * Utilitity to convert this script object to the given type. 4.6 * 4.7 + * @param <T> destination type to convert to 4.8 * @param type destination type to convert to 4.9 * @return converted object 4.10 */
5.1 --- a/src/jdk/nashorn/api/scripting/package-info.java Wed May 28 11:08:07 2014 -0700 5.2 +++ b/src/jdk/nashorn/api/scripting/package-info.java Fri May 30 17:22:38 2014 +0530 5.3 @@ -32,7 +32,8 @@ 5.4 * ScriptEngine nashornEngine = new ScriptEngineManager().getEngineByName("Nashorn"); 5.5 * </pre> 5.6 * <p>Nashorn script engines implement the optional {@link javax.script.Invocable} and {@link javax.script.Compilable} 5.7 - * interfaces, allowing for efficient pre-compilation and repeated execution of scripts. See 5.8 + * interfaces, allowing for efficient pre-compilation and repeated execution of scripts. In addition, 5.9 + * this package provides nashorn specific extension classes, interfaces and methods. See 5.10 * {@link jdk.nashorn.api.scripting.NashornScriptEngineFactory} for further details. 5.11 */ 5.12 package jdk.nashorn.api.scripting;
6.1 --- a/src/jdk/nashorn/internal/ir/annotations/Reference.java Wed May 28 11:08:07 2014 -0700 6.2 +++ b/src/jdk/nashorn/internal/ir/annotations/Reference.java Fri May 30 17:22:38 2014 +0530 6.3 @@ -32,9 +32,7 @@ 6.4 * Reference node in AST, i.e. anything not a copy. Important for 6.5 * AST traversal and cloning. Cloning currently as a rule uses 6.6 * existingOrSame for references and otherwise existingOrCopy 6.7 - * <p> 6.8 */ 6.9 - 6.10 @Retention(value=RetentionPolicy.RUNTIME) 6.11 public @interface Reference { 6.12 // EMPTY