JDK-8023551.js revision 513:54f60d91024c
1184610Salfred/* 2184610Salfred * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3184610Salfred * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4184610Salfred * 5184610Salfred * This code is free software; you can redistribute it and/or modify it 6184610Salfred * under the terms of the GNU General Public License version 2 only, as 7184610Salfred * published by the Free Software Foundation. 8184610Salfred * 9184610Salfred * This code is distributed in the hope that it will be useful, but WITHOUT 10184610Salfred * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11184610Salfred * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12184610Salfred * version 2 for more details (a copy is included in the LICENSE file that 13184610Salfred * accompanied this code). 14184610Salfred * 15184610Salfred * You should have received a copy of the GNU General Public License version 16184610Salfred * 2 along with this work; if not, write to the Free Software Foundation, 17184610Salfred * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18184610Salfred * 19184610Salfred * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20184610Salfred * or visit www.oracle.com if you need additional information or have any 21184610Salfred * questions. 22184610Salfred */ 23184610Salfred 24184610Salfred/** 25184610Salfred * JDK-8023551: Mirror functions can not be invoked using invokeMethod, invokeFunction 26184610Salfred * 27246122Shselasky * @test 28246122Shselasky * @run 29246122Shselasky */ 30194677Sthompsa 31194677Sthompsavar m = new javax.script.ScriptEngineManager(); 32194677Sthompsavar e = m.getEngineByName("nashorn"); 33194677Sthompsa 34194677Sthompsafunction func(x) { 35194677Sthompsa print("func: " + x); 36194677Sthompsa} 37194677Sthompsa 38194677Sthompsae.put("func", func); 39194677Sthompsae.invokeFunction("func", "hello"); 40194677Sthompsa 41194677Sthompsavar obj = e.eval("({ foo: func })"); 42194677Sthompsae.invokeMethod(obj, "foo", "world"); 43194677Sthompsa