When JSON.stringify is called on a ScriptObjectMirror, we get undefined value. JSON.stringify is used as debug aid by nashorn users. ScriptObjectMirror being not handled by JSON.stringify makes it difficult.
D:\src\jdk9-dev\build\windows-x86_64-normal-server-release\images\jdk\bin>.\jjs
jjs> SM = javax.script.ScriptEngineManager
[JavaClass javax.script.ScriptEngineManager]
jjs> e = new SM().getEngineByName("nashorn")
jdk.nashorn.api.scripting.NashornScriptEngine@23348b5d
jjs> JSON.stringify(e.eval("({ foo: 343 })")) === undefined
true
jjs>
This issue was reported by Eric Pederson via nashorn-dev alias.
See also: http://mail.openjdk.java.net/pipermail/nashorn-dev/2016-May/006162.html