InvokeMH.java revision 266
266N/A/*
266N/A * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
266N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
266N/A *
266N/A * This code is free software; you can redistribute it and/or modify it
266N/A * under the terms of the GNU General Public License version 2 only, as
266N/A * published by the Free Software Foundation.
266N/A *
266N/A * This code is distributed in the hope that it will be useful, but WITHOUT
266N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
266N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
266N/A * version 2 for more details (a copy is included in the LICENSE file that
266N/A * accompanied this code).
266N/A *
266N/A * You should have received a copy of the GNU General Public License version
266N/A * 2 along with this work; if not, write to the Free Software Foundation,
266N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
266N/A *
266N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
266N/A * CA 95054 USA or visit www.sun.com if you need additional information or
266N/A * have any questions.
266N/A */
266N/A
266N/A/*
266N/A * @test
266N/A * @bug 6754038
266N/A * @summary Generate call sites for method handle
266N/A * @author jrose
266N/A *
266N/A * @compile -source 7 -target 7 InvokeMH.java
266N/A */
266N/A
266N/A/*
266N/A * Standalone testing:
266N/A * <code>
266N/A * $ cd $MY_REPO_DIR/langtools
266N/A * $ (cd make; make)
266N/A * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java
266N/A * $ javap -c -classpath dist meth.InvokeMH
266N/A * </code>
266N/A */
266N/A
266N/Apackage meth;
266N/A
266N/Aimport java.dyn.MethodHandle;
266N/A
266N/Apublic class InvokeMH {
266N/A void test(MethodHandle mh_SiO,
266N/A MethodHandle mh_vS,
266N/A MethodHandle mh_vi,
266N/A MethodHandle mh_vv) {
266N/A Object o; String s; int i; // for return type testing
266N/A
266N/A // next five must have sig = (String,int)Object
266N/A mh_SiO.invoke("world", 123);
266N/A mh_SiO.invoke("mundus", 456);
266N/A Object k = "kosmos";
266N/A mh_SiO.invoke((String)k, 789);
266N/A o = mh_SiO.invoke((String)null, 000);
266N/A o = mh_SiO.<Object>invoke("arda", -123);
266N/A
266N/A // sig = ()String
266N/A s = mh_vS.<String>invoke();
266N/A
266N/A // sig = ()int
266N/A i = mh_vi.<int>invoke();
266N/A o = mh_vi.<int>invoke();
266N/A //s = mh_vi.<int>invoke(); //BAD
266N/A mh_vi.<int>invoke();
266N/A
266N/A // sig = ()void
266N/A //o = mh_vv.<void>invoke(); //BAD
266N/A mh_vv.<void>invoke();
266N/A }
266N/A}