sundar@1824: /* sundar@1824: * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. sundar@1824: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@1824: * sundar@1824: * This code is free software; you can redistribute it and/or modify it sundar@1824: * under the terms of the GNU General Public License version 2 only, as sundar@1824: * published by the Free Software Foundation. sundar@1824: * sundar@1824: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@1824: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@1824: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@1824: * version 2 for more details (a copy is included in the LICENSE file that sundar@1824: * accompanied this code). sundar@1824: * sundar@1824: * You should have received a copy of the GNU General Public License version sundar@1824: * 2 along with this work; if not, write to the Free Software Foundation, sundar@1824: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@1824: * sundar@1824: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@1824: * or visit www.oracle.com if you need additional information or have any sundar@1824: * questions. sundar@1824: */ sundar@1824: sundar@1824: /** sundar@1824: * JDK-8157160: JSON.stringify does not work on ScriptObjectMirror objects sundar@1824: * sundar@1824: * @test sundar@1824: * @option -scripting sundar@1824: * @run sundar@1824: */ sundar@1824: sundar@1824: var SM = Java.type("javax.script.ScriptEngineManager"); sundar@1824: var AJSO = Java.type("jdk.nashorn.api.scripting.AbstractJSObject"); sundar@1824: var Supplier = Java.type("java.util.function.Supplier"); sundar@1824: sundar@1824: var engine = new SM().getEngineByName("nashorn"); sundar@1824: sundar@1824: // JSON stringify ScriptObjectMirror instances sundar@1824: print(JSON.stringify(engine.eval("({ foo : 42 })"))); sundar@1824: print(JSON.stringify(engine.eval("([5, 6, 76, 7])"))); sundar@1824: print(JSON.stringify(engine.eval(<