Class InvokerUtils
java.lang.Object
org.eclipse.jetty.websocket.core.util.InvokerUtils
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic MethodHandle
bindTo
(MethodHandle methodHandle, Object... objs) Bind optional arguments to provided method handlestatic 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.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 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 MethodHandle
optionalMutatedInvoker
(MethodHandles.Lookup lookup, Class<?> targetClass, Method method, InvokerUtils.Arg... callingArgs) 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.
-
Field Details
-
PARAM_IDENTITY
-
-
Constructor Details
-
InvokerUtils
public InvokerUtils()
-
-
Method Details
-
bindTo
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
methodHandle
was null.
-
mutatedInvoker
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
- theMethodHandles.Lookup
instance 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 MethodHandle mutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, Method method, InvokerUtils.ParamIdentifier paramIdentifier, 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
Method
has. - 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
String
if not found in providedMethod
. - The next parameters are all of the provided
callingArg
types
- Parameters:
lookup
- theMethodHandles.Lookup
instance 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 theMethodType
found 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:
RuntimeException
- when unable to fit Calling Args to Parameter Types
-
optionalMutatedInvoker
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.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.Lookup
instance 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 theMethodType
found 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 MethodHandle optionalMutatedInvoker(MethodHandles.Lookup lookup, Class<?> targetClass, Method method, InvokerUtils.Arg... callingArgs)
-