Example usage for java.lang.invoke MethodHandle asType

List of usage examples for java.lang.invoke MethodHandle asType

Introduction

In this page you can find the example usage for java.lang.invoke MethodHandle asType.

Prototype

public MethodHandle asType(MethodType newType) 

Source Link

Document

Produces an adapter method handle which adapts the type of the current method handle to a new type.

Usage

From source file:org.apache.commons.javaflow.examples.invokedynamic.SimpleDynamicLinkage.java

public static CallSite bootstrapDynamic(final MethodHandles.Lookup caller, final String name,
        final MethodType type) throws NoSuchMethodException, IllegalAccessException {
    final MethodHandles.Lookup lookup = MethodHandles.lookup();
    final Class<?> thisClass = lookup.lookupClass(); // (who am I?)
    final MethodHandle sayHello = lookup.findStatic(thisClass, "sayHello", MethodType.methodType(void.class));
    return new ConstantCallSite(sayHello.asType(type));
}