Package | Description |
---|---|
java.lang.invoke |
The
java.lang.invoke package contains dynamic language support provided directly by
the Java core class libraries and virtual machine. |
Modifier and Type | Method and Description |
---|---|
static MethodHandle |
MethodHandles.arrayElementGetter(Class<?> arrayType)
Return a MethodHandle able to read from the array.
|
static MethodHandle |
MethodHandles.arrayElementSetter(Class<?> arrayType)
Return a MethodHandle able to write to the array.
|
MethodHandle |
MethodHandle.asCollector(Class<?> arrayClass,
int collectCount)
Returns a MethodHandle that collects the requested incoming arguments, which must match the
types in MethodType incomingArgs, into an array of arrayClass, called T.
|
MethodHandle |
MethodHandle.asFixedArity()
Return a fixed arity version of the current MethodHandle.
|
MethodHandle |
MethodHandle.asSpreader(Class<?> arrayClass,
int spreadCount)
Produce a MethodHandle that has an array of type arrayClass as its last argument and replaces the
array with spreadCount arguments from the array before calling the original MethodHandle.
|
MethodHandle |
MethodHandle.asType(MethodType newType)
Returns a MethodHandle that presents as being of MethodType newType.
|
MethodHandle |
MethodHandle.asVarargsCollector(Class<?> arrayParameter)
Create an varargs collector adapter on this MethodHandle.
|
MethodHandle |
MethodHandles.Lookup.bind(Object receiver,
String methodName,
MethodType type)
Return an early-bound method handle to a non-static method.
|
MethodHandle |
MethodHandle.bindTo(Object value)
Bind the value as the first argument to the MethodHandle
|
static MethodHandle |
MethodHandles.catchException(MethodHandle tryHandle,
Class<? extends Throwable> throwableClass,
MethodHandle catchHandle)
Produce a MethodHandle that implements a try-catch block.
|
static MethodHandle |
MethodHandles.collectArguments(MethodHandle target,
int pos,
MethodHandle filter)
Produce a MethodHandle that preprocesses some of the arguments by calling the filter handle.
|
static MethodHandle |
MethodHandles.constant(Class<?> returnType,
Object constantValue)
Create a MethodHandle that returns the constantValue on each invocation.
|
static MethodHandle |
MethodHandles.dropArguments(MethodHandle originalHandle,
int location,
Class<?>... valueTypes)
This method returns a method handle that delegates to the original method handle,
ignoring a particular range of arguments (starting at a given location and
with given types).
|
static MethodHandle |
MethodHandles.dropArguments(MethodHandle originalHandle,
int location,
List<Class<?>> valueTypes)
This method returns a method handle that delegates to the original method handle,
ignoring a particular range of arguments (starting at a given location and
with given types).
|
MethodHandle |
VolatileCallSite.dynamicInvoker() |
MethodHandle |
MutableCallSite.dynamicInvoker() |
MethodHandle |
ConstantCallSite.dynamicInvoker()
Return the target MethodHandle of this CallSite.
|
abstract MethodHandle |
CallSite.dynamicInvoker()
Return a MethodHandle equivalent to the invokedynamic instruction on this CallSite.
|
static MethodHandle |
MethodHandles.exactInvoker(MethodType type)
Return a MethodHandle that is the equivalent of calling
MethodHandles.lookup().findVirtual(MethodHandle.class, "invokeExact", type).
|
static MethodHandle |
MethodHandles.explicitCastArguments(MethodHandle handle,
MethodType type)
Produce an adapter that converts the incoming arguments from type to the underlying MethodHandle's type
and converts the return value as required.
|
static MethodHandle |
MethodHandles.filterArguments(MethodHandle handle,
int startPosition,
MethodHandle... filters)
Produce a MethodHandle that adapts its arguments using the filter methodhandles before calling the underlying handle.
|
static MethodHandle |
MethodHandles.filterReturnValue(MethodHandle handle,
MethodHandle filter)
Return a MethodHandle that will adapt the return value of handle by running the filter
on it and returning the result of the filter.
|
MethodHandle |
MethodHandles.Lookup.findConstructor(Class<?> declaringClass,
MethodType type)
Return a MethodHandle that will create an object of the required class and initialize it using
the constructor method with signature type.
|
MethodHandle |
MethodHandles.Lookup.findGetter(Class<?> clazz,
String fieldName,
Class<?> fieldType)
Return a MethodHandle that provides read access to a field.
|
MethodHandle |
MethodHandles.Lookup.findSetter(Class<?> clazz,
String fieldName,
Class<?> fieldType)
Return a MethodHandle that provides write access to a field.
|
MethodHandle |
MethodHandles.Lookup.findSpecial(Class<?> clazz,
String methodName,
MethodType type,
Class<?> specialToken)
Return a MethodHandle bound to a specific-implementation of a virtual method, as if created by an invokespecial bytecode
using the class specialToken.
|
MethodHandle |
MethodHandles.Lookup.findStatic(Class<?> clazz,
String methodName,
MethodType type)
Return a MethodHandle to a static method.
|
MethodHandle |
MethodHandles.Lookup.findStaticGetter(Class<?> clazz,
String fieldName,
Class<?> fieldType)
Return a MethodHandle that provides read access to a field.
|
MethodHandle |
MethodHandles.Lookup.findStaticSetter(Class<?> clazz,
String fieldName,
Class<?> fieldType)
Return a MethodHandle that provides write access to a field.
|
MethodHandle |
MethodHandles.Lookup.findVirtual(Class<?> clazz,
String methodName,
MethodType type)
Return a MethodHandle to a virtual method.
|
static MethodHandle |
MethodHandles.foldArguments(MethodHandle handle,
MethodHandle preprocessor)
Produce a MethodHandle that preprocesses some of the arguments by calling the preprocessor handle.
|
MethodHandle |
VolatileCallSite.getTarget()
The target MethodHandle is returned as though by a read of a volatile variable.
|
MethodHandle |
MutableCallSite.getTarget() |
MethodHandle |
ConstantCallSite.getTarget()
Return the target MethodHandle of this CallSite.
|
abstract MethodHandle |
CallSite.getTarget()
Return the target MethodHandle of the CallSite.
|
MethodHandle |
SwitchPoint.guardWithTest(MethodHandle target,
MethodHandle fallback)
Returns a method handle which always delegates either to the target or the fallback.
|
static MethodHandle |
MethodHandles.guardWithTest(MethodHandle guard,
MethodHandle trueTarget,
MethodHandle falseTarget)
Produce a MethodHandle that implements an if-else block.
|
static MethodHandle |
MethodHandles.identity(Class<?> classType)
Produce a MethodHandle that acts as an identity function.
|
static MethodHandle |
MethodHandles.insertArguments(MethodHandle originalHandle,
int location,
Object... values)
This method returns a method handle that delegates to the original method handle,
adding a particular range of arguments (starting at a given location and
with given types).
|
static MethodHandle |
MethodHandles.invoker(MethodType type)
Return a MethodHandle that is the equivalent of calling
MethodHandles.lookup().findVirtual(MethodHandle.class, "invoke", type).
|
static MethodHandle |
MethodHandles.permuteArguments(MethodHandle handle,
MethodType permuteType,
int... permute)
Produce a MethodHandle that will permute the incoming arguments according to the
permute array.
|
static MethodHandle |
MethodHandles.spreadInvoker(MethodType type,
int fixedArgCount)
Return a MethodHandle that is able to invoke a MethodHandle of type as though by
invoke after spreading the final Object[] parameter.
|
static MethodHandle |
MethodHandles.throwException(Class<?> returnType,
Class<? extends Throwable> exception)
Return a MethodHandle that will throw the passed in Exception object.
|
MethodHandle |
MethodHandles.Lookup.unreflect(Method method)
Make a MethodHandle to the Reflect method.
|
MethodHandle |
MethodHandles.Lookup.unreflectConstructor(Constructor<?> method)
Return a MethodHandle for the reflect constructor.
|
MethodHandle |
MethodHandles.Lookup.unreflectGetter(Field field)
Create a MethodHandle that returns the value of the Reflect field.
|
MethodHandle |
MethodHandles.Lookup.unreflectSetter(Field field)
Create a MethodHandle that sets the value of the Reflect field.
|
MethodHandle |
MethodHandles.Lookup.unreflectSpecial(Method method,
Class<?> specialToken)
Return a MethodHandle for the Reflect method, that will directly call the requested method
as through from the class
specialToken . |
static MethodHandle |
MethodHandleProxies.wrapperInstanceTarget(Object x)
Produces or recovers a target method handle which is behaviorally
equivalent to the unique method of this wrapper instance.
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
MethodHandleProxies.asInterfaceInstance(Class<T> intfc,
MethodHandle target)
Produces an instance of the given single-method interface which redirects
its calls to the given method handle.
|
static MethodHandle |
MethodHandles.catchException(MethodHandle tryHandle,
Class<? extends Throwable> throwableClass,
MethodHandle catchHandle)
Produce a MethodHandle that implements a try-catch block.
|
static MethodHandle |
MethodHandles.collectArguments(MethodHandle target,
int pos,
MethodHandle filter)
Produce a MethodHandle that preprocesses some of the arguments by calling the filter handle.
|
static MethodHandle |
MethodHandles.dropArguments(MethodHandle originalHandle,
int location,
Class<?>... valueTypes)
This method returns a method handle that delegates to the original method handle,
ignoring a particular range of arguments (starting at a given location and
with given types).
|
static MethodHandle |
MethodHandles.dropArguments(MethodHandle originalHandle,
int location,
List<Class<?>> valueTypes)
This method returns a method handle that delegates to the original method handle,
ignoring a particular range of arguments (starting at a given location and
with given types).
|
static MethodHandle |
MethodHandles.explicitCastArguments(MethodHandle handle,
MethodType type)
Produce an adapter that converts the incoming arguments from type to the underlying MethodHandle's type
and converts the return value as required.
|
static MethodHandle |
MethodHandles.filterArguments(MethodHandle handle,
int startPosition,
MethodHandle... filters)
Produce a MethodHandle that adapts its arguments using the filter methodhandles before calling the underlying handle.
|
static MethodHandle |
MethodHandles.filterArguments(MethodHandle handle,
int startPosition,
MethodHandle... filters)
Produce a MethodHandle that adapts its arguments using the filter methodhandles before calling the underlying handle.
|
static MethodHandle |
MethodHandles.filterReturnValue(MethodHandle handle,
MethodHandle filter)
Return a MethodHandle that will adapt the return value of handle by running the filter
on it and returning the result of the filter.
|
static MethodHandle |
MethodHandles.foldArguments(MethodHandle handle,
MethodHandle preprocessor)
Produce a MethodHandle that preprocesses some of the arguments by calling the preprocessor handle.
|
MethodHandle |
SwitchPoint.guardWithTest(MethodHandle target,
MethodHandle fallback)
Returns a method handle which always delegates either to the target or the fallback.
|
static MethodHandle |
MethodHandles.guardWithTest(MethodHandle guard,
MethodHandle trueTarget,
MethodHandle falseTarget)
Produce a MethodHandle that implements an if-else block.
|
static MethodHandle |
MethodHandles.insertArguments(MethodHandle originalHandle,
int location,
Object... values)
This method returns a method handle that delegates to the original method handle,
adding a particular range of arguments (starting at a given location and
with given types).
|
static CallSite |
LambdaMetafactory.metafactory(MethodHandles.Lookup caller,
String invokedName,
MethodType invokedType,
MethodType samMethodType,
MethodHandle implMethod,
MethodType instantiatedMethodType)
Facilitates the creation of simple "function objects" that implement one
or more interfaces by delegation to a provided
MethodHandle ,
after appropriate type adaptation and partial evaluation of arguments. |
static MethodHandle |
MethodHandles.permuteArguments(MethodHandle handle,
MethodType permuteType,
int... permute)
Produce a MethodHandle that will permute the incoming arguments according to the
permute array.
|
static <T extends Member> |
MethodHandles.reflectAs(Class<T> expected,
MethodHandle target)
Gets the underlying Member of the provided
target MethodHandle. |
MethodHandleInfo |
MethodHandles.Lookup.revealDirect(MethodHandle target)
Cracks a MethodHandle, which allows access to its symbolic parts.
|
void |
VolatileCallSite.setTarget(MethodHandle nextTarget)
Set the CallSite's target to be nextTarget.
|
void |
MutableCallSite.setTarget(MethodHandle newTarget) |
void |
ConstantCallSite.setTarget(MethodHandle newTarget)
Throws UnsupportedOperationException as a ConstantCallSite is permanently
bound to its initial target MethodHandle.
|
abstract void |
CallSite.setTarget(MethodHandle nextTarget)
Set the CallSite's target to be nextTarget.
|
Constructor and Description |
---|
ConstantCallSite(MethodHandle permanentTarget)
Create a ConstantCallSite with a target MethodHandle that cannot change.
|
ConstantCallSite(MethodType targetType,
MethodHandle hook)
Create a ConstantCallSite and assign the hook MethodHandle's result to its permanent target.
|
MutableCallSite(MethodHandle mutableTarget)
Create a MutableCallSite permanently set to the same type as the mutableTarget and using
the mutableTarget as the initial target value.
|
VolatileCallSite(MethodHandle volatileTarget)
Create a VolatileCallSite with the same type as the volatileTarget
and the initial target set to volatileTarget.
|
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.