Top Inners Fields Constructors Methods
org.eclipse.jetty.websocket.core.util

public Class InvokerUtils

extends Object
Class Inheritance
Imports
java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, java.lang.reflect.Method, java.util.ArrayList, .Arrays, .List, .Objects, org.eclipse.jetty.websocket.core.exception.InvalidSignatureException, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static interface
private static class

Field Summary

Modifier and TypeField and Description
private static final Logger
public static final InvokerUtils.ParamIdentifier

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
public static MethodHandle

Returns:

the bound MethodHandle, or null if the provided methodHandle was null.
bindTo
(MethodHandle
the method handle to bind to
methodHandle
,
Object...
the list of optional objects to bind to.
objs
)

Bind optional arguments to provided method handle

public static MethodHandle
mutatedInvoker(MethodHandles.Lookup lookup, Class<?>
the target class for invocations of the resulting MethodHandle (also known as parameter 0)
targetClass
,
Method
the method to invoke
method
,
InvokerUtils.Arg...
the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in the MethodHandle#type() in the order specified in this array.
callingArgs
)

Build a MethodHandle that can call the method with the calling args provided.

public static MethodHandle

Returns:

the MethodHandle for this set of CallingArgs
mutatedInvoker
(MethodHandles.Lookup lookup, Class<?>
the target class for invocations of the resulting MethodHandle (also known as parameter 0)
targetClass
,
Method
the method to invoke
method
,
InvokerUtils.ParamIdentifier
the mechanism to identify parameters in method
paramIdentifier
,
String[]
the array of named variables. This is the array of named arguments that the target method might have. The resulting MethodHandle will include all of these namedVariables as the first non-object arguments in the MethodType found on the returned MethodHandle#type()
namedVariables
,
InvokerUtils.Arg...
the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in the MethodHandle#type() in the order specified in this array.
callingArgs
)

Create a MethodHandle that performs the following layers

  1. MethodHandles#permuteArguments(MethodHandle, MethodType, int...) - moving calling Args around to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwords
  2. MethodHandles#dropArguments(MethodHandle, int, Class[]) - to drop the unused calling args
  3. MethodHandle#invoke(Object...) - to call the specific method
private static MethodHandle
mutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, boolean throwOnFailure, Method method, InvokerUtils.ParamIdentifier paramIdentifier, String[] namedVariables, InvokerUtils.Arg... rawCallingArgs)

public static MethodHandle

Returns:

the MethodHandle for this set of CallingArgs, or null if not possible to create MethodHandle with CallingArgs to provided method
optionalMutatedInvoker
(MethodHandles.Lookup lookup, Class<?>
the target class for invocations of the resulting MethodHandle (also known as parameter 0)
targetClass
,
Method
the method to invoke
method
,
InvokerUtils.ParamIdentifier
the mechanism to identify parameters in method
paramIdentifier
,
String[]
the array of named variables. This is the array of named arguments that the target method might have. The resulting MethodHandle will include all of these namedVariables as the first non-object arguments in the MethodType found on the returned MethodHandle#type()
namedVariables
,
InvokerUtils.Arg...
the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in the MethodHandle#type() in the order specified in this array.
callingArgs
)

Create an optional MethodHandle that performs the following layers.

public static MethodHandle
optionalMutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, Method method, InvokerUtils.Arg... callingArgs)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG
PARAM_IDENTITYback to summary
public static final InvokerUtils.ParamIdentifier PARAM_IDENTITY

Constructor Detail

InvokerUtilsback to summary
public InvokerUtils()

Method Detail

appendTypeListback to summary
private static void appendTypeList(StringBuilder str, InvokerUtils.Arg[] args)
bindToback to summary
public static MethodHandle bindTo(MethodHandle methodHandle, Object... objs)

Bind optional arguments to provided method handle

Parameters
methodHandle:MethodHandle

the method handle to bind to

objs:Object[]

the list of optional objects to bind to.

Returns:MethodHandle

the bound MethodHandle, or null if the provided methodHandle was null.

mutatedInvokerback to summary
public static MethodHandle mutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, Method method, InvokerUtils.Arg... callingArgs)

Build a MethodHandle that can call the method with the calling args provided.

Might need to drop calling args and/or reorder the calling args to fit the actual method being called.

Parameters
lookup:MethodHandles.Lookup

the java.lang.invoke.MethodHandles.Lookup instance to use.

targetClass:Class<?>

the target class for invocations of the resulting MethodHandle (also known as parameter 0)

method:Method

the method to invoke

callingArgs:InvokerUtils.Arg[]

the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in the MethodHandle#type() in the order specified in this array.

mutatedInvokerback to summary
public static MethodHandle mutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, Method method, InvokerUtils.ParamIdentifier paramIdentifier, String[] namedVariables, InvokerUtils.Arg... callingArgs)

Create a MethodHandle that performs the following layers

  1. MethodHandles#permuteArguments(MethodHandle, MethodType, int...) - moving calling Args around to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwords
  2. MethodHandles#dropArguments(MethodHandle, int, Class[]) - to drop the unused calling args
  3. MethodHandle#invoke(Object...) - to call the specific method

The returned MethodHandle.MethodHandle#type() assumes the following:

  1. Return type will be what the provided Method has.
  2. The first parameter is the type of class provided in the targetClass.
  3. The next parameters are all of the found type's of the named arguments, or type String if not found in provided Method.
  4. The next parameters are all of the provided callingArg types
Parameters
lookup:MethodHandles.Lookup

the java.lang.invoke.MethodHandles.Lookup instance to use.

targetClass:Class<?>

the target class for invocations of the resulting MethodHandle (also known as parameter 0)

method:Method

the method to invoke

paramIdentifier:InvokerUtils.ParamIdentifier

the mechanism to identify parameters in method

namedVariables:String[]

the array of named variables. This is the array of named arguments that the target method might have. The resulting MethodHandle will include all of these namedVariables as the first non-object arguments in the MethodType found on the returned MethodHandle#type()

callingArgs:InvokerUtils.Arg[]

the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in the MethodHandle#type() in the order specified in this array.

Returns:MethodHandle

the MethodHandle for this set of CallingArgs

Exceptions
RuntimeException:
when unable to fit Calling Args to Parameter Types
mutatedInvokerback to summary
private static MethodHandle mutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, boolean throwOnFailure, Method method, InvokerUtils.ParamIdentifier paramIdentifier, String[] namedVariables, InvokerUtils.Arg... rawCallingArgs)
optionalMutatedInvokerback to summary
public static MethodHandle optionalMutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, Method method, InvokerUtils.ParamIdentifier paramIdentifier, String[] namedVariables, InvokerUtils.Arg... callingArgs)

Create an optional MethodHandle that performs the following layers.

  1. MethodHandles#permuteArguments(MethodHandle, MethodType, int...) - moving calling Args around to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwords
  2. MethodHandles#dropArguments(MethodHandle, int, Class[]) - to drop the unused calling args
  3. MethodHandle#invoke(Object...) - to call the specific method
Parameters
lookup:MethodHandles.Lookup

the java.lang.invoke.MethodHandles.Lookup instance to use.

targetClass:Class<?>

the target class for invocations of the resulting MethodHandle (also known as parameter 0)

method:Method

the method to invoke

paramIdentifier:InvokerUtils.ParamIdentifier

the mechanism to identify parameters in method

namedVariables:String[]

the array of named variables. This is the array of named arguments that the target method might have. The resulting MethodHandle will include all of these namedVariables as the first non-object arguments in the MethodType found on the returned MethodHandle#type()

callingArgs:InvokerUtils.Arg[]

the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in the MethodHandle#type() in the order specified in this array.

Returns:MethodHandle

the MethodHandle for this set of CallingArgs, or null if not possible to create MethodHandle with CallingArgs to provided method

optionalMutatedInvokerback to summary
public static MethodHandle optionalMutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, Method method, InvokerUtils.Arg... callingArgs)
org.eclipse.jetty.websocket.core.util back to summary

public Class InvokerUtils.Arg

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Class<?>
private boolean
private String
private boolean
private final Class<?>

Constructor Summary

AccessConstructor and Description
public
Arg(Class<?> type)

public
Arg(Class<?> type, String name)

Method Summary

Modifier and TypeMethod and Description
public InvokerUtils.Arg
public Class<?>
public String
public Class<?>
public boolean
public boolean
public InvokerUtils.Arg
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

convertedTypeback to summary
private Class<?> convertedType
convertibleback to summary
private boolean convertible
nameback to summary
private String name
requiredback to summary
private boolean required
typeback to summary
private final Class<?> type

Constructor Detail

Argback to summary
public Arg(Class<?> type)
Argback to summary
public Arg(Class<?> type, String name)

Method Detail

convertibleback to summary
public InvokerUtils.Arg convertible()
getConvertedTypeback to summary
public Class<?> getConvertedType()
getNameback to summary
public String getName()
getTypeback to summary
public Class<?> getType()
isRequiredback to summary
public boolean isRequired()
matchesback to summary
public boolean matches(InvokerUtils.Arg other)
requiredback to summary
public InvokerUtils.Arg required()
org.eclipse.jetty.websocket.core.util back to summary

public Interface InvokerUtils.ParamIdentifier

Known Direct Implementers
org.eclipse.jetty.websocket.core.util.InvokerUtils.ParamIdentity

Method Summary

Modifier and TypeMethod and Description
public InvokerUtils.Arg
getParamArg(Method method, Class<?> paramType, int idx)

Method Detail

getParamArgback to summary
public InvokerUtils.Arg getParamArg(Method method, Class<?> paramType, int idx)
org.eclipse.jetty.websocket.core.util back to summary

private Class InvokerUtils.ParamIdentity

extends Object
implements ParamIdentifier
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.websocket.core.util.InvokerUtils.ParamIdentity
All Implemented Interfaces
org.eclipse.jetty.websocket.core.util.InvokerUtils.ParamIdentifier

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public InvokerUtils.Arg
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ParamIdentityback to summary
private ParamIdentity()

Method Detail

getParamArgback to summary
public InvokerUtils.Arg getParamArg(Method method, Class<?> paramType, int idx)

Implements org.eclipse.jetty.websocket.core.util.InvokerUtils.ParamIdentifier.getParamArg.

Annotations
@Override