Search in sources :

Example 16 with MutableCallSite

use of java.lang.invoke.MutableCallSite in project openj9 by eclipse.

the class BootstrapMethods method gwtBootstrap.

public static CallSite gwtBootstrap(Lookup ignored, String name, MethodType type) throws Throwable {
    Lookup lookup = lookup();
    MethodHandle double_string = lookup.findStatic(BootstrapMethods.class, "dup", methodType(String.class, String.class));
    MethodHandle double_integer = lookup.findStatic(BootstrapMethods.class, "dup", methodType(String.class, Integer.class));
    MethodHandle double_object = lookup.findStatic(BootstrapMethods.class, "dup", methodType(String.class, Object.class));
    MethodHandle isInteger = lookup.findStatic(BootstrapMethods.class, "isInteger", methodType(boolean.class, Object.class));
    MethodHandle isString = lookup.findStatic(BootstrapMethods.class, "isString", methodType(boolean.class, Object.class));
    MethodHandle handle = guardWithTest(isString, double_string.asType(methodType(String.class, Object.class)), double_object);
    handle = guardWithTest(isInteger, double_integer.asType(methodType(String.class, Object.class)), handle);
    return new MutableCallSite(handle);
}
Also used : MutableCallSite(java.lang.invoke.MutableCallSite) Lookup(java.lang.invoke.MethodHandles.Lookup) MethodHandle(java.lang.invoke.MethodHandle)

Example 17 with MutableCallSite

use of java.lang.invoke.MutableCallSite in project openj9 by eclipse.

the class BootstrapMethods method foldBootstrap.

public static CallSite foldBootstrap(Lookup ignored, String name, MethodType type) throws Throwable {
    Lookup lookup = lookup();
    MethodHandle add = lookup.findStatic(BootstrapMethods.class, "add", methodType(int.class, int.class, int.class));
    MethodHandle fold = foldArguments(add, identity(int.class));
    fold = foldArguments(add, fold);
    return new MutableCallSite(fold);
}
Also used : MutableCallSite(java.lang.invoke.MutableCallSite) Lookup(java.lang.invoke.MethodHandles.Lookup) MethodHandle(java.lang.invoke.MethodHandle)

Aggregations

MutableCallSite (java.lang.invoke.MutableCallSite)17 MethodHandle (java.lang.invoke.MethodHandle)15 Lookup (java.lang.invoke.MethodHandles.Lookup)7 Test (org.testng.annotations.Test)7 MethodType (java.lang.invoke.MethodType)4 SwitchPoint (java.lang.invoke.SwitchPoint)3 ConstantCallSite (java.lang.invoke.ConstantCallSite)1 WrongMethodTypeException (java.lang.invoke.WrongMethodTypeException)1