Example usage for java.lang.invoke ConstantCallSite ConstantCallSite

List of usage examples for java.lang.invoke ConstantCallSite ConstantCallSite

Introduction

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

Prototype

public ConstantCallSite(MethodHandle target) 

Source Link

Document

Creates a call site with a permanent target.

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));
}