test/tools/javac/meth/InvokeMHTrans.java

Tue, 28 Dec 2010 15:54:52 -0800

author
ohair
date
Tue, 28 Dec 2010 15:54:52 -0800
changeset 798
4868a36f6fd8
parent 674
584365f256a7
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

     1 /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  *
     4  * This code is free software; you can redistribute it and/or modify it
     5  * under the terms of the GNU General Public License version 2 only, as
     6  * published by the Free Software Foundation.
     7  *
     8  * This code is distributed in the hope that it will be useful, but WITHOUT
     9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    11  * version 2 for more details (a copy is included in the LICENSE file that
    12  * accompanied this code).
    13  *
    14  * You should have received a copy of the GNU General Public License version
    15  * 2 along with this work; if not, write to the Free Software Foundation,
    16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    17  *
    18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19  * or visit www.oracle.com if you need additional information or have any
    20  * questions.
    21  */
    23 /*
    24  * @test
    25  * @bug 6754038 6979327
    26  * @summary Generate call sites for method handle
    27  * @author jrose
    28  *
    29  * @compile/fail/ref=InvokeMHTrans.out -Werror -XDrawDiagnostics -source 7 -target 7 InvokeMHTrans.java
    30  */
    32 /*
    33  * Standalone testing:
    34  * <code>
    35  * $ cd $MY_REPO_DIR/langtools
    36  * $ (cd make; make)
    37  * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java
    38  * $ javap -c -classpath dist meth.InvokeMH
    39  * </code>
    40  */
    42 package meth;
    44 import java.dyn.MethodHandle;
    46 public class InvokeMHTrans {
    47     void test(MethodHandle mh_SiO,
    48               MethodHandle mh_vS,
    49               MethodHandle mh_vi,
    50               MethodHandle mh_vv) throws Throwable {
    51         Object o; String s; int i;  // for return type testing
    53         // next five must have sig = (String,int)Object
    54         mh_SiO.invokeExact("world", 123);
    55         mh_SiO.invokeExact("mundus", 456);
    56         Object k = "kosmos";
    57         mh_SiO.invokeExact((String)k, 789);
    58         o = mh_SiO.invokeExact((String)null, 000);
    59         o = mh_SiO.<Object>invokeExact("arda", -123);
    61         // sig = ()String
    62         s = mh_vS.<String>invokeExact();
    64         // sig = ()int
    65         i = mh_vi.<int>invokeExact();
    66         o = mh_vi.<int>invokeExact();
    67         //s = mh_vi.<int>invokeExact(); //BAD
    68         mh_vi.<int>invokeExact();
    70         // sig = ()void
    71         //o = mh_vv.<void>invokeExact(); //BAD
    72         mh_vv.<void>invokeExact();
    73     }
    75     void testGen(MethodHandle mh_SiO,
    76                  MethodHandle mh_vS,
    77                  MethodHandle mh_vi,
    78                  MethodHandle mh_vv) throws Throwable {
    79         Object o; String s; int i;  // for return type testing
    81         // next five must have sig = (*,*)*
    82         mh_SiO.invokeGeneric((Object)"world", (Object)123);
    83         mh_SiO.<void>invokeGeneric((Object)"mundus", (Object)456);
    84         Object k = "kosmos";
    85         mh_SiO.invokeGeneric(k, 789);
    86         o = mh_SiO.invokeGeneric(null, 000);
    87         o = mh_SiO.<Object>invokeGeneric("arda", -123);
    89         // sig = ()String
    90         o = mh_vS.invokeGeneric();
    92         // sig = ()int
    93         i = mh_vi.<int>invokeGeneric();
    94         o = mh_vi.invokeGeneric();
    95         //s = mh_vi.<int>invokeGeneric(); //BAD
    96         mh_vi.<void>invokeGeneric();
    98         // sig = ()void
    99         //o = mh_vv.<void>invokeGeneric(); //BAD
   100         o = mh_vv.invokeGeneric();
   101     }
   102 }

mercurial