MethodHandles (Java SE 26 & JDK 26)
-
Nested Class Summary
Nested Classes
static final classA lookup object is a factory for creating method handles, when the creation requires access checking.
-
Method Summary
Produces a method handle constructing arrays of a desired type, as if by the
anewarraybytecode.Produces a method handle giving read access to elements of an array, as if by the
aaloadbytecode.Produces a method handle giving write access to elements of an array, as if by the
astorebytecode.Produces a VarHandle giving access to elements of an array of type
arrayClass.Produces a method handle returning the length of an array, as if by the
arraylengthbytecode.Produces a VarHandle giving access to elements of a
byte[]array viewed as if it were a different primitive array type, such asint[]orlong[].Produces a VarHandle giving access to elements of a
ByteBufferviewed as if it were an array of elements of a different primitive component type to that ofbyte, such asint[]orlong[].Makes a method handle which adapts a target method handle, by running it inside an exception handler.
static <T> TReturns the class data associated with the lookup class of the given
callerlookup object, ornull.static <T> TReturns the element at the specified index in the class data, if the class data associated with the lookup class of the given
callerlookup object is aList.Adapts a target method handle by pre-processing a sub-sequence of its arguments with a filter (another method handle).
Adapts a target var handle by pre-processing a sub-sequence of its coordinate values with a filter (a method handle).
Produces a method handle of the requested return type which returns the given constant value every time it is invoked.
Constructs a loop that runs a given number of iterations.
Constructs a loop that counts over a range of numbers.
Constructs a
do-whileloop from an initializer, a body, and a predicate.Produces a method handle which will discard some dummy arguments before calling some other specified target method handle.
Produces a method handle which will discard some dummy arguments before calling some other specified target method handle.
Adapts a target method handle to match the given parameter type list.
Returns a var handle which will discard some dummy coordinates before delegating to the target var handle.
Drop the return value of the target handle (if any).
Produces a method handle of the requested type which ignores any arguments, does nothing, and returns a suitable default depending on the return type.
Produces a special invoker method handle which can be used to invoke any method handle of the given type, as if by
invokeExact.Produces a method handle which adapts the type of the given method handle to a new type by pairwise argument and return type conversion.
Adapts a target method handle by pre-processing one or more of its arguments, each with its own unary filter function, and then calling the target with each pre-processed argument replaced by the result of its corresponding filter function.
Adapts a target var handle by pre-processing incoming coordinate values using unary filter functions.
Adapts a target method handle by post-processing its return value (if any) with a filter (another method handle).
Adapts a target var handle by pre-processing incoming and outgoing values using a pair of filter functions.
Adapts a target method handle by pre-processing some of its arguments, starting at a given position, and then calling the target with the result of the pre-processing, inserted into the original sequence of arguments just before the folded arguments.
Adapts a target method handle by pre-processing some of its arguments, and then calling the target with the result of the pre-processing, inserted into the original sequence of arguments.
Makes a method handle which adapts a target method handle, by guarding it with a test, a boolean-valued method handle.
Produces a method handle which returns its sole argument when invoked.
Provides a target method handle with one or more bound arguments in advance of the method handle's invocation.
Provides a target var handle with one or more bound coordinates in advance of the var handle's invocation.
Produces a special invoker method handle which can be used to invoke any method handle compatible with the given type, as if by
invoke.Constructs a loop that ranges over the values produced by an
Iterator<T>.lookup()Returns a
lookup objectwith full capabilities to emulate all supported bytecode behaviors of the caller.Constructs a method handle representing a loop with several loop variables that are updated and checked upon each iteration.
Produces a method handle which adapts the calling sequence of the given method handle to a new type, by reordering the arguments.
Provides a var handle which adapts the coordinate values of the target var handle, by re-arranging them so that the new coordinates match the provided ones.
Returns a
lookupobject on a target class to emulate all supported bytecode behaviors, including private access.static <T extends Member>
TProduces a method handle which will invoke any method handle of the given
type, with a given number of trailing arguments replaced by a single trailingObject[]array.Creates a table switch method handle, which can be used to switch over a set of target method handles, based on a given target index, called selector.
Produces a method handle which will throw exceptions of the given
exType.Makes a method handle that adapts a
targetmethod handle by wrapping it in atry-finallyblock.Produces a special invoker method handle which can be used to invoke a signature-polymorphic access mode method on any VarHandle whose associated access mode type is compatible with the given type.
Produces a special invoker method handle which can be used to invoke a signature-polymorphic access mode method on any VarHandle whose associated access mode type is compatible with the given type.
Constructs a
whileloop from an initializer, a body, and a predicate.Produces a constant method handle of the requested return type which returns the default value for that type every time it is invoked.
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitCreates and returns a copy of this object.
booleanIndicates whether some other object is "equal to" this one.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.intReturns a hash code value for this object.
final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
Returns a string representation of the object.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Method Details
-
lookup
-
publicLookup
-
privateLookupIn
-
classData
-
classDataAt
-
reflectAs
-
arrayConstructor
-
arrayLength
-
arrayElementGetter
-
arrayElementSetter
-
arrayElementVarHandle
-
byteArrayViewVarHandle
-
byteBufferViewVarHandle
-
spreadInvoker
-
exactInvoker
-
invoker
-
varHandleExactInvoker
-
varHandleInvoker
-
explicitCastArguments
-
permuteArguments
-
constant
-
identity
-
zero
-
empty
-
insertArguments
-
dropArguments
-
dropArguments
-
dropArgumentsToMatch
-
dropReturn
-
filterArguments
-
collectArguments
-
filterReturnValue
-
foldArguments
-
foldArguments
-
guardWithTest
-
catchException
-
throwException
-
loop
-
whileLoop
-
doWhileLoop
-
countedLoop
-
countedLoop
-
iteratedLoop
-
tryFinally
-
tableSwitch
-
filterValue
-
filterCoordinates
-
insertCoordinates
-
permuteCoordinates
-
collectCoordinates
-
dropCoordinates
-