- java.lang.Object
-
- org.eclipse.jetty.websocket.util.InvokerUtils
-
public class InvokerUtils extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInvokerUtils.Argstatic interfaceInvokerUtils.ParamIdentifier
-
Field Summary
Fields Modifier and Type Field Description static InvokerUtils.ParamIdentifierPARAM_IDENTITY
-
Constructor Summary
Constructors Constructor Description InvokerUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.invoke.MethodHandlebindTo(java.lang.invoke.MethodHandle methodHandle, java.lang.Object... objs)Bind optional arguments to provided method handlestatic java.lang.invoke.MethodHandlemutatedInvoker(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> targetClass, java.lang.reflect.Method method, InvokerUtils.Arg... callingArgs)Build a MethodHandle that can call the method with the calling args provided.static java.lang.invoke.MethodHandlemutatedInvoker(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> targetClass, java.lang.reflect.Method method, InvokerUtils.ParamIdentifier paramIdentifier, java.lang.String[] namedVariables, InvokerUtils.Arg... callingArgs)Create a MethodHandle that performs the following layersMethodHandles.permuteArguments(MethodHandle, MethodType, int...)- moving calling Args around to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwordsMethodHandles.dropArguments(MethodHandle, int, Class[])- to drop the unused calling argsMethodHandle.invoke(Object...)- to call the specific methodstatic java.lang.invoke.MethodHandleoptionalMutatedInvoker(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> targetClass, java.lang.reflect.Method method, InvokerUtils.Arg... callingArgs)static java.lang.invoke.MethodHandleoptionalMutatedInvoker(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> targetClass, java.lang.reflect.Method method, InvokerUtils.ParamIdentifier paramIdentifier, java.lang.String[] namedVariables, InvokerUtils.Arg... callingArgs)Create an optional MethodHandle that performs the following layers.
-
-
-
Field Detail
-
PARAM_IDENTITY
public static final InvokerUtils.ParamIdentifier PARAM_IDENTITY
-
-
Method Detail
-
bindTo
public static java.lang.invoke.MethodHandle bindTo(java.lang.invoke.MethodHandle methodHandle, java.lang.Object... objs)Bind optional arguments to provided method handle- Parameters:
methodHandle- the method handle to bind toobjs- the list of optional objects to bind to.- Returns:
- the bound MethodHandle, or null if the provided
methodHandlewas null.
-
mutatedInvoker
public static java.lang.invoke.MethodHandle mutatedInvoker(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> targetClass, java.lang.reflect.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- theMethodHandles.Lookupinstance to use.targetClass- the target class for invocations of the resulting MethodHandle (also known as parameter 0)method- the method to invokecallingArgs- the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in theMethodHandle.type()in the order specified in this array.
-
mutatedInvoker
public static java.lang.invoke.MethodHandle mutatedInvoker(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> targetClass, java.lang.reflect.Method method, InvokerUtils.ParamIdentifier paramIdentifier, java.lang.String[] namedVariables, InvokerUtils.Arg... callingArgs)Create a MethodHandle that performs the following layersMethodHandles.permuteArguments(MethodHandle, MethodType, int...)- moving calling Args around to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwordsMethodHandles.dropArguments(MethodHandle, int, Class[])- to drop the unused calling argsMethodHandle.invoke(Object...)- to call the specific method
The returned
MethodHandle.MethodHandle.type()assumes the following:- Return type will be what the provided
Methodhas. - The first parameter is the type of class provided in the
targetClass. - The next parameters are all of the found type's of the named arguments, or type
Stringif not found in providedMethod. - The next parameters are all of the provided
callingArgtypes
- Parameters:
lookup- theMethodHandles.Lookupinstance to use.targetClass- the target class for invocations of the resulting MethodHandle (also known as parameter 0)method- the method to invokeparamIdentifier- the mechanism to identify parameters in methodnamedVariables- 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 theMethodTypefound on the returnedMethodHandle.type()callingArgs- the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in theMethodHandle.type()in the order specified in this array.- Returns:
- the MethodHandle for this set of CallingArgs
- Throws:
java.lang.RuntimeException- when unable to fit Calling Args to Parameter Types
-
optionalMutatedInvoker
public static java.lang.invoke.MethodHandle optionalMutatedInvoker(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> targetClass, java.lang.reflect.Method method, InvokerUtils.ParamIdentifier paramIdentifier, java.lang.String[] namedVariables, InvokerUtils.Arg... callingArgs)Create an optional MethodHandle that performs the following layers.MethodHandles.permuteArguments(MethodHandle, MethodType, int...)- moving calling Args around to fit actual actual method parameter arguments (in proper order), with remaining (unused) calling args afterwordsMethodHandles.dropArguments(MethodHandle, int, Class[])- to drop the unused calling argsMethodHandle.invoke(Object...)- to call the specific method
- Parameters:
lookup- theMethodHandles.Lookupinstance to use.targetClass- the target class for invocations of the resulting MethodHandle (also known as parameter 0)method- the method to invokeparamIdentifier- the mechanism to identify parameters in methodnamedVariables- 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 theMethodTypefound on the returnedMethodHandle.type()callingArgs- the calling arguments. This is the array of arguments that will always be passed into the returned MethodHandle. They will be present in theMethodHandle.type()in the order specified in this array.- Returns:
- the MethodHandle for this set of CallingArgs, or null if not possible to create MethodHandle with CallingArgs to provided method
-
optionalMutatedInvoker
public static java.lang.invoke.MethodHandle optionalMutatedInvoker(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<?> targetClass, java.lang.reflect.Method method, InvokerUtils.Arg... callingArgs)
-
-