sundar@1120: /* sundar@1120: * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. sundar@1120: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@1120: * sundar@1120: * This code is free software; you can redistribute it and/or modify it sundar@1120: * under the terms of the GNU General Public License version 2 only, as sundar@1120: * published by the Free Software Foundation. sundar@1120: * sundar@1120: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@1120: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@1120: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@1120: * version 2 for more details (a copy is included in the LICENSE file that sundar@1120: * accompanied this code). sundar@1120: * sundar@1120: * You should have received a copy of the GNU General Public License version sundar@1120: * 2 along with this work; if not, write to the Free Software Foundation, sundar@1120: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@1120: * sundar@1120: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@1120: * or visit www.oracle.com if you need additional information or have any sundar@1120: * questions. sundar@1120: */ sundar@1120: sundar@1120: /** sundar@1120: * JDK-8067136: BrowserJSObjectLinker does not handle call on JSObjects sundar@1120: * sundar@1120: * @test sundar@1120: * @option -scripting sundar@1120: * @run sundar@1120: */ sundar@1120: sundar@1120: // call on netscape.javascript.JSObject sundar@1120: sundar@1120: function main() { sundar@1120: var JSObject; sundar@1120: try { sundar@1120: JSObject = Java.type("netscape.javascript.JSObject"); sundar@1120: } catch (e) { sundar@1120: if (e instanceof java.lang.ClassNotFoundException) { sundar@1120: // pass vacuously by emitting the .EXPECTED file content sundar@1120: var str = readFully(__DIR__ + "JDK-8067136.js.EXPECTED"); sundar@1120: print(str.substring(0, str.length - 1)); sundar@1120: return; sundar@1120: } else{ sundar@1120: fail("unexpected exception for JSObject", e); sundar@1120: } sundar@1120: } sundar@1120: test(JSObject); sundar@1120: } sundar@1120: sundar@1120: function test(JSObject) { sundar@1120: var obj = new (Java.extend(JSObject))() { sundar@1120: getMember: function(name) { sundar@1120: if (name == "func") { sundar@1120: return new (Java.extend(JSObject)) { sundar@1120: call: function(n) { sundar@1120: print("func called"); sundar@1120: } sundar@1120: } sundar@1120: } sundar@1120: return name.toUpperCase(); sundar@1120: }, sundar@1120: sundar@1120: }; sundar@1120: sundar@1120: obj.func(); sundar@1120: } sundar@1120: sundar@1120: main();