7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /**
27 <p>
28 Nashorn is a runtime environment for programs written in ECMAScript 5.1.
29 </p>
30 <h1>Usage</h1>
31 The recommended way to use Nashorn is through the <a href="http://jcp.org/en/jsr/detail?id=223" target="_top">JSR-223
32 "Scripting for the Java Platform"</a> APIs found in the {@link javax.script} package. Usually, you'll obtain a
33 {@link javax.script.ScriptEngine} instance for Nashorn using:
34 <pre>
35 import javax.script.*;
36 ...
37 ScriptEngine nashornEngine = new ScriptEngineManager().getEngineByName("nashorn");
38 </pre>
39 and then use it just as you would any other JSR-223 script engine. See
40 <a href="jdk/nashorn/api/scripting/package-summary.html">{@code jdk.nashorn.api.scripting}</a> package
41 for details.
42 <h1>Compatibility</h1>
43 Nashorn is 100% compliant with the <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm"
44 target="_top">ECMA-262 Standard, Edition 5.1</a>. It requires a Java Virtual Machine that implements the
45 <a href="http://jcp.org/en/jsr/detail?id=292" target="_top">JSR-292 "Supporting Dynamically Typed Languages on the Java
46 Platform"</a> specification (often referred to as "invokedynamic"), as well as the already mentioned JSR-223.
73 primitive string type, you can only rely on it being a {@code java.lang.CharSequence}, and if the value is a number, you
74 can only rely on it being a {@code java.lang.Number}. If the Java method declared parameter type is more specific (e.g.
75 {@code java.lang.String} or {@code java.lang.Double}), then Nashorn will of course ensure the required type is passed.
76 <h2>SAM types</h2>
77 As a special extension when invoking Java methods, ECMAScript function objects can be passed in place of an argument
78 whose Java type is so-called "single abstract method" or "SAM" type. While this name usually covers single-method
79 interfaces, Nashorn is a bit more versatile, and it recognizes a type as a SAM type if all its abstract methods are
80 overloads of the same name, and it is either an interface, or it is an abstract class with
81 a no-arg constructor. The type itself must be public, while the constructor and the methods can be either public or
82 protected. If there are multiple abstract overloads of the same name, the single function will serve as the shared
83 implementation for all of them, <em>and additionally it will also override any non-abstract methods of the same name</em>.
84 This is done to be consistent with the fact that ECMAScript does not have the concept of overloaded methods.
85 <h2>The {@code Java} object</h2>
86 Nashorn exposes a non-standard global object named {@code Java} that is the primary API entry point into Java
87 platform-specific functionality. You can use it to create instances of Java classes, convert from Java arrays to native
88 arrays and back, and so on.
89 <h2>Other non-standard built-in objects</h2>
90 In addition to {@code Java}, Nashorn also exposes some other non-standard built-in objects:
91 {@code JSAdapter}, {@code JavaImporter}, {@code Packages}
92
93 @moduleGraph
94 @since 9
95 */
96 module jdk.scripting.nashorn {
97 requires java.logging;
98 requires transitive java.scripting;
99 requires jdk.dynalink;
100
101 exports jdk.nashorn.api.scripting;
102 exports jdk.nashorn.api.tree;
103
104 exports jdk.nashorn.internal.runtime to
105 jdk.scripting.nashorn.shell;
106 exports jdk.nashorn.internal.objects to
107 jdk.scripting.nashorn.shell;
108 exports jdk.nashorn.tools to
109 jdk.scripting.nashorn.shell;
110
111 provides javax.script.ScriptEngineFactory
112 with jdk.nashorn.api.scripting.NashornScriptEngineFactory;
|
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /**
27 Provides the implementation of Nashorn script engine and
28 the runtime environment for programs written in ECMAScript 5.1.
29 <p>
30 Nashorn is a runtime environment for programs written in ECMAScript 5.1.
31 </p>
32 <h1>Usage</h1>
33 The recommended way to use Nashorn is through the <a href="http://jcp.org/en/jsr/detail?id=223" target="_top">JSR-223
34 "Scripting for the Java Platform"</a> APIs found in the {@link javax.script} package. Usually, you'll obtain a
35 {@link javax.script.ScriptEngine} instance for Nashorn using:
36 <pre>
37 import javax.script.*;
38 ...
39 ScriptEngine nashornEngine = new ScriptEngineManager().getEngineByName("nashorn");
40 </pre>
41 and then use it just as you would any other JSR-223 script engine. See
42 <a href="jdk/nashorn/api/scripting/package-summary.html">{@code jdk.nashorn.api.scripting}</a> package
43 for details.
44 <h1>Compatibility</h1>
45 Nashorn is 100% compliant with the <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm"
46 target="_top">ECMA-262 Standard, Edition 5.1</a>. It requires a Java Virtual Machine that implements the
47 <a href="http://jcp.org/en/jsr/detail?id=292" target="_top">JSR-292 "Supporting Dynamically Typed Languages on the Java
48 Platform"</a> specification (often referred to as "invokedynamic"), as well as the already mentioned JSR-223.
75 primitive string type, you can only rely on it being a {@code java.lang.CharSequence}, and if the value is a number, you
76 can only rely on it being a {@code java.lang.Number}. If the Java method declared parameter type is more specific (e.g.
77 {@code java.lang.String} or {@code java.lang.Double}), then Nashorn will of course ensure the required type is passed.
78 <h2>SAM types</h2>
79 As a special extension when invoking Java methods, ECMAScript function objects can be passed in place of an argument
80 whose Java type is so-called "single abstract method" or "SAM" type. While this name usually covers single-method
81 interfaces, Nashorn is a bit more versatile, and it recognizes a type as a SAM type if all its abstract methods are
82 overloads of the same name, and it is either an interface, or it is an abstract class with
83 a no-arg constructor. The type itself must be public, while the constructor and the methods can be either public or
84 protected. If there are multiple abstract overloads of the same name, the single function will serve as the shared
85 implementation for all of them, <em>and additionally it will also override any non-abstract methods of the same name</em>.
86 This is done to be consistent with the fact that ECMAScript does not have the concept of overloaded methods.
87 <h2>The {@code Java} object</h2>
88 Nashorn exposes a non-standard global object named {@code Java} that is the primary API entry point into Java
89 platform-specific functionality. You can use it to create instances of Java classes, convert from Java arrays to native
90 arrays and back, and so on.
91 <h2>Other non-standard built-in objects</h2>
92 In addition to {@code Java}, Nashorn also exposes some other non-standard built-in objects:
93 {@code JSAdapter}, {@code JavaImporter}, {@code Packages}
94
95 @provides javax.script.ScriptEngineFactory
96 @moduleGraph
97 @since 9
98 */
99 module jdk.scripting.nashorn {
100 requires java.logging;
101 requires transitive java.scripting;
102 requires jdk.dynalink;
103
104 exports jdk.nashorn.api.scripting;
105 exports jdk.nashorn.api.tree;
106
107 exports jdk.nashorn.internal.runtime to
108 jdk.scripting.nashorn.shell;
109 exports jdk.nashorn.internal.objects to
110 jdk.scripting.nashorn.shell;
111 exports jdk.nashorn.tools to
112 jdk.scripting.nashorn.shell;
113
114 provides javax.script.ScriptEngineFactory
115 with jdk.nashorn.api.scripting.NashornScriptEngineFactory;
|