jrose@267: /* mcimadamore@674: * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. jrose@267: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jrose@267: * jrose@267: * This code is free software; you can redistribute it and/or modify it jrose@267: * under the terms of the GNU General Public License version 2 only, as jrose@267: * published by the Free Software Foundation. jrose@267: * jrose@267: * This code is distributed in the hope that it will be useful, but WITHOUT jrose@267: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jrose@267: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jrose@267: * version 2 for more details (a copy is included in the LICENSE file that jrose@267: * accompanied this code). jrose@267: * jrose@267: * You should have received a copy of the GNU General Public License version jrose@267: * 2 along with this work; if not, write to the Free Software Foundation, jrose@267: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jrose@267: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jrose@267: */ jrose@267: jrose@267: /* jrose@267: * @test mcimadamore@674: * @bug 6754038 6979327 jrose@267: * @summary Generate call sites for method handle jrose@267: * @author jrose jrose@267: * mcimadamore@674: * @compile -source 7 -target 7 -XDallowTransitionalJSR292=no InvokeMH.java jrose@267: */ jrose@267: jrose@267: /* jrose@267: * Standalone testing: jrose@267: * jrose@267: * $ cd $MY_REPO_DIR/langtools jrose@267: * $ (cd make; make) jrose@267: * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java jrose@267: * $ javap -c -classpath dist meth.InvokeMH jrose@267: * jrose@267: */ jrose@267: jrose@267: package meth; jrose@267: ksrini@957: import java.lang.invoke.MethodHandle; jrose@267: jrose@267: public class InvokeMH { jrose@267: void test(MethodHandle mh_SiO, jrose@267: MethodHandle mh_vS, jrose@267: MethodHandle mh_vi, jrose@571: MethodHandle mh_vv) throws Throwable { jrose@267: Object o; String s; int i; // for return type testing jrose@267: jrose@267: // next five must have sig = (String,int)Object jrose@571: mh_SiO.invokeExact("world", 123); jrose@571: mh_SiO.invokeExact("mundus", 456); jrose@267: Object k = "kosmos"; jrose@571: mh_SiO.invokeExact((String)k, 789); jrose@571: o = mh_SiO.invokeExact((String)null, 000); mcimadamore@674: o = (Object) mh_SiO.invokeExact("arda", -123); jrose@267: jrose@267: // sig = ()String mcimadamore@674: s = (String) mh_vS.invokeExact(); jrose@267: jrose@267: // sig = ()int mcimadamore@674: i = (int) mh_vi.invokeExact(); mcimadamore@674: o = (int) mh_vi.invokeExact(); jrose@267: jrose@267: // sig = ()void mcimadamore@674: mh_vv.invokeExact(); jrose@571: } jrose@571: jrose@571: void testGen(MethodHandle mh_SiO, jrose@571: MethodHandle mh_vS, jrose@571: MethodHandle mh_vi, jrose@571: MethodHandle mh_vv) throws Throwable { jrose@571: Object o; String s; int i; // for return type testing jrose@571: jrose@571: // next five must have sig = (*,*)* jjh@1021: o = mh_SiO.invoke((Object)"world", (Object)123); jjh@1021: mh_SiO.invoke((Object)"mundus", (Object)456); jrose@571: Object k = "kosmos"; jjh@1021: o = mh_SiO.invoke(k, 789); jjh@1021: o = mh_SiO.invoke(null, 000); jjh@1021: o = mh_SiO.invoke("arda", -123); jrose@571: jrose@571: // sig = ()String jjh@1021: o = mh_vS.invoke(); jrose@571: jrose@571: // sig = ()int jjh@1021: i = (int) mh_vi.invoke(); jjh@1021: o = (int) mh_vi.invoke(); jjh@1021: mh_vi.invoke(); jrose@571: jrose@571: // sig = ()void jjh@1021: mh_vv.invoke(); jjh@1021: o = mh_vv.invoke(); jrose@267: } jrose@267: }