Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If you want to explicitly wrap a script object to a ScriptObjectMirror instance and pass along to any API (which may even accept Object), you can use jdk.nashorn.api.scripting.ScriptUtils class's wrap method. Similarly you can explicitly unwrap a ScriptObjectMirror to a script object via unwrap method. Note that unwrap won't unwrap the object if it is not a wrapper of object created with the current global object. In most instances you won't have to wrap/unwrap manually. In Java code, always operate on ScriptObjectMirror instances and in script you'll always see normal ScriptObject (unwrapped) instances automatically.

JavaDoc for

...

Nashorn specific API

...

jdk.nashorn.api.* is considered to be fairly stable the only Nashorn specific API package (extension to javax.script). Anything else is considered to be Nashorn implementation detail and can/will be changed in future.Java 8 jdk.nashorn.api javadoc

jdk8: https://docs.oracle.com/javase/8/docs/jdk/api/nashorn/jdk/nashorn/api/scripting/JSObject.html

jdk9 http://download.java.net/jdk9/docs/jdk/api/nashorn/

...