sundar@1837: /* sundar@1837: * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. sundar@1837: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@1837: * sundar@1837: * This code is free software; you can redistribute it and/or modify it sundar@1837: * under the terms of the GNU General Public License version 2 only, as sundar@1837: * published by the Free Software Foundation. sundar@1837: * sundar@1837: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@1837: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@1837: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@1837: * version 2 for more details (a copy is included in the LICENSE file that sundar@1837: * accompanied this code). sundar@1837: * sundar@1837: * You should have received a copy of the GNU General Public License version sundar@1837: * 2 along with this work; if not, write to the Free Software Foundation, sundar@1837: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@1837: * sundar@1837: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@1837: * or visit www.oracle.com if you need additional information or have any sundar@1837: * questions. sundar@1837: */ sundar@1837: sundar@1837: /** sundar@1837: * JDK-8158467: AccessControlException is thrown on public Java class access if "script app loader" is set to null sundar@1837: * sundar@1837: * @option -scripting sundar@1837: * @test sundar@1837: * @run sundar@1837: */ sundar@1837: sundar@1837: var Factory = Java.type("jdk.nashorn.api.scripting.NashornScriptEngineFactory"); sundar@1837: var fac = new Factory(); sundar@1837: sundar@1837: // This script has to be given RuntimePermission("nashorn.setConfig") sundar@1837: var e = fac["getScriptEngine(java.lang.ClassLoader)"](null); sundar@1837: sundar@1837: print(e.eval("java.lang.System")); sundar@1837: print(e.eval("({ foo: 42})").foo); sundar@1837: print((e.eval("function(x) x*x"))(31)); sundar@1837: sundar@1837: e.put("output", print); sundar@1837: var runnable = e.eval(<