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
lagergren@1086 | 1 | /* |
lagergren@1086 | 2 | * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. |
lagergren@1086 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
lagergren@1086 | 4 | * |
lagergren@1086 | 5 | * This code is free software; you can redistribute it and/or modify it |
lagergren@1086 | 6 | * under the terms of the GNU General Public License version 2 only, as |
lagergren@1086 | 7 | * published by the Free Software Foundation. |
lagergren@1086 | 8 | * |
lagergren@1086 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
lagergren@1086 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
lagergren@1086 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
lagergren@1086 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
lagergren@1086 | 13 | * accompanied this code). |
lagergren@1086 | 14 | * |
lagergren@1086 | 15 | * You should have received a copy of the GNU General Public License version |
lagergren@1086 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
lagergren@1086 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
lagergren@1086 | 18 | * |
lagergren@1086 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
lagergren@1086 | 20 | * or visit www.oracle.com if you need additional information or have any |
lagergren@1086 | 21 | * questions. |
lagergren@1086 | 22 | */ |
lagergren@1086 | 23 | |
lagergren@1086 | 24 | /** |
lagergren@1086 | 25 | * JDK-8057825 : A failed apply to call generation should NOT reuse the |
lagergren@1086 | 26 | * best apply to call generation so far - because it may not fit!!! |
lagergren@1086 | 27 | * |
lagergren@1086 | 28 | * @test |
lagergren@1086 | 29 | * @run |
lagergren@1086 | 30 | */ |
lagergren@1086 | 31 | |
lagergren@1086 | 32 | function createApplier(f) { |
lagergren@1086 | 33 | function applier() { |
lagergren@1086 | 34 | f.apply(this, arguments); // no transform applied here |
lagergren@1086 | 35 | } |
lagergren@1086 | 36 | return applier; |
lagergren@1086 | 37 | } |
lagergren@1086 | 38 | |
lagergren@1086 | 39 | function printer(x,y) { |
lagergren@1086 | 40 | print(x + " and " + y); |
lagergren@1086 | 41 | } |
lagergren@1086 | 42 | |
lagergren@1086 | 43 | var printerApplier = createApplier(printer); |
lagergren@1086 | 44 | printerApplier(); |
lagergren@1086 | 45 | printerApplier.apply(this, ["foo", "bar"]); |