test/tools/javac/meth/InvokeMH.java

Fri, 26 Jun 2009 19:12:41 -0700

author
jjg
date
Fri, 26 Jun 2009 19:12:41 -0700
changeset 309
664edca41e34
parent 267
e2722bd43f3a
child 554
9d9f26857129
child 571
f0e3ec1f9d9f
permissions
-rw-r--r--

6855544: add missing files
Reviewed-by: jjg, mcimadamore, darcy
Contributed-by: mernst@cs.washington.edu, mali@csail.mit.edu, mpapi@csail.mit.edu

jrose@267 1 /*
jrose@267 2 * Copyright 2008 Sun Microsystems, Inc. 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 *
jrose@267 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
jrose@267 20 * CA 95054 USA or visit www.sun.com if you need additional information or
jrose@267 21 * have any questions.
jrose@267 22 */
jrose@267 23
jrose@267 24 /*
jrose@267 25 * @test
jrose@267 26 * @bug 6754038
jrose@267 27 * @summary Generate call sites for method handle
jrose@267 28 * @author jrose
jrose@267 29 *
jrose@267 30 * @compile -source 7 -target 7 InvokeMH.java
jrose@267 31 */
jrose@267 32
jrose@267 33 /*
jrose@267 34 * Standalone testing:
jrose@267 35 * <code>
jrose@267 36 * $ cd $MY_REPO_DIR/langtools
jrose@267 37 * $ (cd make; make)
jrose@267 38 * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java
jrose@267 39 * $ javap -c -classpath dist meth.InvokeMH
jrose@267 40 * </code>
jrose@267 41 */
jrose@267 42
jrose@267 43 package meth;
jrose@267 44
jrose@267 45 import java.dyn.MethodHandle;
jrose@267 46
jrose@267 47 public class InvokeMH {
jrose@267 48 void test(MethodHandle mh_SiO,
jrose@267 49 MethodHandle mh_vS,
jrose@267 50 MethodHandle mh_vi,
jrose@267 51 MethodHandle mh_vv) {
jrose@267 52 Object o; String s; int i; // for return type testing
jrose@267 53
jrose@267 54 // next five must have sig = (String,int)Object
jrose@267 55 mh_SiO.invoke("world", 123);
jrose@267 56 mh_SiO.invoke("mundus", 456);
jrose@267 57 Object k = "kosmos";
jrose@267 58 mh_SiO.invoke((String)k, 789);
jrose@267 59 o = mh_SiO.invoke((String)null, 000);
jrose@267 60 o = mh_SiO.<Object>invoke("arda", -123);
jrose@267 61
jrose@267 62 // sig = ()String
jrose@267 63 s = mh_vS.<String>invoke();
jrose@267 64
jrose@267 65 // sig = ()int
jrose@267 66 i = mh_vi.<int>invoke();
jrose@267 67 o = mh_vi.<int>invoke();
jrose@267 68 //s = mh_vi.<int>invoke(); //BAD
jrose@267 69 mh_vi.<int>invoke();
jrose@267 70
jrose@267 71 // sig = ()void
jrose@267 72 //o = mh_vv.<void>invoke(); //BAD
jrose@267 73 mh_vv.<void>invoke();
jrose@267 74 }
jrose@267 75 }

mercurial