Fri, 10 Dec 2010 15:24:17 +0000
6199075: Unambiguous varargs method calls flagged as ambiguous
Summary: javac does not implement overload resolution w.r.t. varargs methods as described in the JLS
Reviewed-by: jjg
jrose@267 | 1 | /* |
mcimadamore@674 | 2 | * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
jrose@267 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jrose@267 | 4 | * |
jrose@267 | 5 | * This code is free software; you can redistribute it and/or modify it |
jrose@267 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jrose@267 | 7 | * published by the Free Software Foundation. |
jrose@267 | 8 | * |
jrose@267 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jrose@267 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jrose@267 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jrose@267 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jrose@267 | 13 | * accompanied this code). |
jrose@267 | 14 | * |
jrose@267 | 15 | * You should have received a copy of the GNU General Public License version |
jrose@267 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jrose@267 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jrose@267 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
jrose@267 | 22 | */ |
jrose@267 | 23 | |
jrose@267 | 24 | /* |
jrose@267 | 25 | * @test |
mcimadamore@674 | 26 | * @bug 6754038 6979327 |
jrose@267 | 27 | * @summary Generate call sites for method handle |
jrose@267 | 28 | * @author jrose |
jrose@267 | 29 | * |
jrose@267 | 30 | * @library .. |
mcimadamore@674 | 31 | * @compile -source 7 -target 7 -XDinvokedynamic -XDallowTransitionalJSR292=no InvokeDyn.java |
jrose@267 | 32 | */ |
jrose@267 | 33 | //No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn |
jrose@267 | 34 | |
jrose@267 | 35 | /* |
jrose@267 | 36 | * Standalone testing: |
jrose@267 | 37 | * <code> |
jrose@267 | 38 | * $ cd $MY_REPO_DIR/langtools |
jrose@267 | 39 | * $ (cd make; make) |
jrose@267 | 40 | * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java |
jrose@267 | 41 | * $ javap -c -classpath dist meth.InvokeDyn |
jrose@267 | 42 | * </code> |
jrose@267 | 43 | */ |
jrose@267 | 44 | |
jrose@267 | 45 | package meth; |
jrose@267 | 46 | |
mcimadamore@674 | 47 | import java.dyn.*; |
jrose@267 | 48 | |
jrose@267 | 49 | public class InvokeDyn { |
mcimadamore@674 | 50 | class CS extends CallSite { |
mcimadamore@674 | 51 | CS(Object x, Object y, Object z) { throw new RuntimeException(); } |
mcimadamore@674 | 52 | } |
mcimadamore@674 | 53 | //@BootstrapMethod(CS.class) //note: requires 6964498 |
jrose@571 | 54 | void test() throws Throwable { |
jrose@267 | 55 | Object x = "hello"; |
mcimadamore@674 | 56 | Object ojunk; int ijunk; |
mcimadamore@674 | 57 | ojunk = InvokeDynamic.greet(x, "world", 123); |
mcimadamore@674 | 58 | ojunk = InvokeDynamic.greet(x, "mundus", 456); |
mcimadamore@674 | 59 | ojunk = InvokeDynamic.greet(x, "kosmos", 789); |
mcimadamore@674 | 60 | ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14); |
jjg@752 | 61 | //InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null); |
mcimadamore@674 | 62 | ijunk = (int) InvokeDynamic.invoke("goodbye"); |
jrose@267 | 63 | } |
jrose@267 | 64 | } |