Tue, 01 Sep 2015 18:28:11 +0530
8068901: Surprising behavior with more than one functional interface on a class
8068903: Can't invoke vararg @FunctionalInterface methods
Reviewed-by: attila, hannesw
sundar@1120 | 1 | /* |
sundar@1120 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
sundar@1120 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
sundar@1120 | 4 | * |
sundar@1120 | 5 | * This code is free software; you can redistribute it and/or modify it |
sundar@1120 | 6 | * under the terms of the GNU General Public License version 2 only, as |
sundar@1120 | 7 | * published by the Free Software Foundation. |
sundar@1120 | 8 | * |
sundar@1120 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
sundar@1120 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
sundar@1120 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
sundar@1120 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
sundar@1120 | 13 | * accompanied this code). |
sundar@1120 | 14 | * |
sundar@1120 | 15 | * You should have received a copy of the GNU General Public License version |
sundar@1120 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
sundar@1120 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
sundar@1120 | 18 | * |
sundar@1120 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
sundar@1120 | 20 | * or visit www.oracle.com if you need additional information or have any |
sundar@1120 | 21 | * questions. |
sundar@1120 | 22 | */ |
sundar@1120 | 23 | |
sundar@1120 | 24 | /** |
sundar@1120 | 25 | * JDK-8067136: BrowserJSObjectLinker does not handle call on JSObjects |
sundar@1120 | 26 | * |
sundar@1120 | 27 | * @test |
sundar@1120 | 28 | * @option -scripting |
sundar@1120 | 29 | * @run |
sundar@1120 | 30 | */ |
sundar@1120 | 31 | |
sundar@1120 | 32 | // call on netscape.javascript.JSObject |
sundar@1120 | 33 | |
sundar@1120 | 34 | function main() { |
sundar@1120 | 35 | var JSObject; |
sundar@1120 | 36 | try { |
sundar@1120 | 37 | JSObject = Java.type("netscape.javascript.JSObject"); |
sundar@1120 | 38 | } catch (e) { |
sundar@1120 | 39 | if (e instanceof java.lang.ClassNotFoundException) { |
sundar@1120 | 40 | // pass vacuously by emitting the .EXPECTED file content |
sundar@1120 | 41 | var str = readFully(__DIR__ + "JDK-8067136.js.EXPECTED"); |
sundar@1120 | 42 | print(str.substring(0, str.length - 1)); |
sundar@1120 | 43 | return; |
sundar@1120 | 44 | } else{ |
sundar@1120 | 45 | fail("unexpected exception for JSObject", e); |
sundar@1120 | 46 | } |
sundar@1120 | 47 | } |
sundar@1120 | 48 | test(JSObject); |
sundar@1120 | 49 | } |
sundar@1120 | 50 | |
sundar@1120 | 51 | function test(JSObject) { |
sundar@1120 | 52 | var obj = new (Java.extend(JSObject))() { |
sundar@1120 | 53 | getMember: function(name) { |
sundar@1120 | 54 | if (name == "func") { |
sundar@1120 | 55 | return new (Java.extend(JSObject)) { |
sundar@1120 | 56 | call: function(n) { |
sundar@1120 | 57 | print("func called"); |
sundar@1120 | 58 | } |
sundar@1120 | 59 | } |
sundar@1120 | 60 | } |
sundar@1120 | 61 | return name.toUpperCase(); |
sundar@1120 | 62 | }, |
sundar@1120 | 63 | |
sundar@1120 | 64 | }; |
sundar@1120 | 65 | |
sundar@1120 | 66 | obj.func(); |
sundar@1120 | 67 | } |
sundar@1120 | 68 | |
sundar@1120 | 69 | main(); |