Home | History | Annotate | Download | only in 132-invoke-polymorphic
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 import java.lang.invoke.MethodHandle;
     18 
     19 public class TestInvokePolymorphic {
     20     public static void testInvokeVoidReturnNoArgs(MethodHandle mh) throws Throwable {
     21         mh.invoke();
     22     }
     23 
     24     public static void testInvokeExactVoidReturnNoArgs(MethodHandle mh) throws Throwable {
     25         mh.invokeExact();
     26     }
     27 
     28     public static int testInvokeIntReturnNoArgs(MethodHandle mh) throws Throwable {
     29         return (int) mh.invoke();
     30     }
     31 
     32     public static int testInvokeExactIntReturnNoArgs(MethodHandle mh) throws Throwable {
     33         return (int) mh.invokeExact();
     34     }
     35 
     36     public static long testInvokeLongReturnNoArgs(MethodHandle mh) throws Throwable {
     37         return (long) mh.invoke();
     38     }
     39 
     40     public static long testInvokeExactLongReturnNoArgs(MethodHandle mh) throws Throwable {
     41         return (long) mh.invokeExact();
     42     }
     43 
     44     public static double testInvokeDoubleReturnNoArgs(MethodHandle mh) throws Throwable {
     45         return (double) mh.invoke();
     46     }
     47 
     48     public static double testInvokeExactDoubleReturnNoArgs(MethodHandle mh) throws Throwable {
     49         return (double) mh.invokeExact();
     50     }
     51 
     52     public static double testInvokeDoubleReturn2Arguments(MethodHandle mh, Object o, long l)
     53             throws Throwable {
     54         return (double) mh.invoke(o, l);
     55     }
     56 
     57     public static double testInvokeExactDoubleReturn2Arguments(MethodHandle mh, Object o, long l)
     58             throws Throwable {
     59         return (double) mh.invokeExact(o, l);
     60     }
     61 
     62     public static void testInvokeVoidReturn3IntArguments(MethodHandle mh, int x, int y, int z)
     63             throws Throwable {
     64         mh.invoke( x, y, z);
     65     }
     66 
     67     public static void testInvokeExactVoidReturn3IntArguments(MethodHandle mh, int x, int y, int z)
     68             throws Throwable {
     69         mh.invokeExact(x, y, z);
     70     }
     71 
     72     public static void testInvokeVoidReturn3Arguments(MethodHandle mh, Object o, long l, double d)
     73             throws Throwable {
     74         mh.invoke(o, l, d);
     75     }
     76 
     77     public static void testInvokeExactVoidReturn3Arguments(MethodHandle mh, Object o, long l,
     78                                                            double d) throws Throwable {
     79         mh.invokeExact(o, l, d);
     80     }
     81 
     82     public static int testInvokeIntReturn5Arguments(MethodHandle mh, Object o, long l, double d,
     83                                                     float f, String s) throws Throwable {
     84         return (int) mh.invoke(o, l, d, f, s);
     85     }
     86 
     87     public static int testInvokeExactIntReturn5Arguments(MethodHandle mh, Object o, long l,
     88                                                          double d, float f, String s)
     89             throws Throwable {
     90         return (int) mh.invokeExact(o, l, d, f, s);
     91     }
     92 }
     93