266N/A/*
673N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. 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 *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
266N/A */
266N/A
266N/A/*
266N/A * @test
673N/A * @bug 6754038 6979327
266N/A * @summary Generate call sites for method handle
266N/A * @author jrose
266N/A *
673N/A * @compile -source 7 -target 7 -XDallowTransitionalJSR292=no 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
956N/Aimport java.lang.invoke.MethodHandle;
266N/A
266N/Apublic class InvokeMH {
266N/A void test(MethodHandle mh_SiO,
266N/A MethodHandle mh_vS,
266N/A MethodHandle mh_vi,
570N/A MethodHandle mh_vv) throws Throwable {
266N/A Object o; String s; int i; // for return type testing
266N/A
266N/A // next five must have sig = (String,int)Object
570N/A mh_SiO.invokeExact("world", 123);
570N/A mh_SiO.invokeExact("mundus", 456);
266N/A Object k = "kosmos";
570N/A mh_SiO.invokeExact((String)k, 789);
570N/A o = mh_SiO.invokeExact((String)null, 000);
673N/A o = (Object) mh_SiO.invokeExact("arda", -123);
266N/A
266N/A // sig = ()String
673N/A s = (String) mh_vS.invokeExact();
266N/A
266N/A // sig = ()int
673N/A i = (int) mh_vi.invokeExact();
673N/A o = (int) mh_vi.invokeExact();
266N/A
266N/A // sig = ()void
673N/A mh_vv.invokeExact();
570N/A }
570N/A
570N/A void testGen(MethodHandle mh_SiO,
570N/A MethodHandle mh_vS,
570N/A MethodHandle mh_vi,
570N/A MethodHandle mh_vv) throws Throwable {
570N/A Object o; String s; int i; // for return type testing
570N/A
570N/A // next five must have sig = (*,*)*
1018N/A o = mh_SiO.invoke((Object)"world", (Object)123);
1018N/A mh_SiO.invoke((Object)"mundus", (Object)456);
570N/A Object k = "kosmos";
1018N/A o = mh_SiO.invoke(k, 789);
1018N/A o = mh_SiO.invoke(null, 000);
1018N/A o = mh_SiO.invoke("arda", -123);
570N/A
570N/A // sig = ()String
1018N/A o = mh_vS.invoke();
570N/A
570N/A // sig = ()int
1018N/A i = (int) mh_vi.invoke();
1018N/A o = (int) mh_vi.invoke();
1018N/A mh_vi.invoke();
570N/A
570N/A // sig = ()void
1018N/A mh_vv.invoke();
1018N/A o = mh_vv.invoke();
266N/A }
266N/A}