Compartilhar via


MethodHandles Class

Definition

This class consists exclusively of static methods that operate on or return method handles.

[Android.Runtime.Register("java/lang/invoke/MethodHandles", ApiSince=26, DoNotGenerateAcw=true)]
public class MethodHandles : Java.Lang.Object
[<Android.Runtime.Register("java/lang/invoke/MethodHandles", ApiSince=26, DoNotGenerateAcw=true)>]
type MethodHandles = class
    inherit Object
Inheritance
MethodHandles
Attributes

Remarks

This class consists exclusively of static methods that operate on or return method handles. They fall into several categories: <ul> <li>Lookup methods which help create method handles for methods and fields. <li>Combinator methods, which combine or transform pre-existing method handles into new ones. <li>Other factory methods to create method handles that emulate other common JVM operations or control flow patterns. </ul>

Added in 1.7.

Java documentation for java.lang.invoke.MethodHandles.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

MethodHandles(IntPtr, JniHandleOwnership)

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass
ThresholdType

Methods

ArrayConstructor(Class)

Produces a method handle constructing arrays of a desired type, as if by the anewarray bytecode.

ArrayElementGetter(Class)

Produces a method handle giving read access to elements of an array.

ArrayElementSetter(Class)

Produces a method handle giving write access to elements of an array.

ArrayElementVarHandle(Class)

Produces a VarHandle giving access to elements of an array of type arrayClass.

ArrayLength(Class)

Produces a method handle returning the length of an array, as if by the arraylength bytecode.

ByteArrayViewVarHandle(Class, ByteOrder)

Produces a VarHandle giving access to elements of a byte[] array viewed as if it were a different primitive array type, such as int[] or long[].

ByteBufferViewVarHandle(Class, ByteOrder)

Produces a VarHandle giving access to elements of a ByteBuffer viewed as if it were an array of elements of a different primitive component type to that of byte, such as int[] or long[].

CatchException(MethodHandle, Class, MethodHandle)

Makes a method handle which adapts a target method handle, by running it inside an exception handler.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CollectArguments(MethodHandle, Int32, MethodHandle)

Adapts a target method handle by pre-processing a sub-sequence of its arguments with a filter (another method handle).

Constant(Class, Object)

Produces a method handle of the requested return type which returns the given constant value every time it is invoked.

CountedLoop(MethodHandle, MethodHandle, MethodHandle, MethodHandle)

Constructs a loop that counts over a range of numbers.

CountedLoop(MethodHandle, MethodHandle, MethodHandle)

Constructs a loop that runs a given number of iterations.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
DoWhileLoop(MethodHandle, MethodHandle, MethodHandle)

Constructs a do-while loop from an initializer, a body, and a predicate.

DropArguments(MethodHandle, Int32, Class[])

Produces a method handle which will discard some dummy arguments before calling some other specified target method handle.

DropArguments(MethodHandle, Int32, IList<Class>)

Produces a method handle which will discard some placeholder arguments before calling some other specified target method handle.

DropArgumentsToMatch(MethodHandle, Int32, IList<Class>, Int32)

Adapts a target method handle to match the given parameter type list.

DropReturn(MethodHandle)

Drop the return value of the target handle (if any).

Empty(MethodType)

Produces a method handle of the requested type which ignores any arguments, does nothing, and returns a suitable default depending on the return type.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
ExactInvoker(MethodType)

Produces a special <em>invoker method handle</em> which can be used to invoke any method handle of the given type, as if by MethodHandle#invokeExact invokeExact.

ExplicitCastArguments(MethodHandle, MethodType)

Produces a method handle which adapts the type of the given method handle to a new type by pairwise argument and return type conversion.

FilterArguments(MethodHandle, Int32, MethodHandle[])

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.

FilterReturnValue(MethodHandle, MethodHandle)

Adapts a target method handle by post-processing its return value (if any) with a filter (another method handle).

FoldArguments(MethodHandle, Int32, MethodHandle)

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.

FoldArguments(MethodHandle, MethodHandle)

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.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GuardWithTest(MethodHandle, MethodHandle, MethodHandle)

Makes a method handle which adapts a target method handle, by guarding it with a test, a boolean-valued method handle.

Identity(Class)

Produces a method handle which returns its sole argument when invoked.

InsertArguments(MethodHandle, Int32, Object[])

Provides a target method handle with one or more <em>bound arguments</em> in advance of the method handle's invocation.

InvokeLookup()

Returns a Lookup lookup object with full capabilities to emulate all supported bytecode behaviors of the caller.

Invoker(MethodType)

Produces a special <em>invoker method handle</em> which can be used to invoke any method handle compatible with the given type, as if by MethodHandle#invoke invoke.

IteratedLoop(MethodHandle, MethodHandle, MethodHandle)

Constructs a loop that ranges over the values produced by an Iterator<T>.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Loop(MethodHandle[][])

Constructs a method handle representing a loop with several loop variables that are updated and checked upon each iteration.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
PermuteArguments(MethodHandle, MethodType, Int32[])

Produces a method handle which adapts the calling sequence of the given method handle to a new type, by reordering the arguments.

PrivateLookupIn(Class, MethodHandles+Lookup)
PublicLookup()

Returns a Lookup lookup object which is trusted minimally.

ReflectAs(Class, MethodHandle)

Performs an unchecked "crack" of a direct method handle.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SpreadInvoker(MethodType, Int32)

Produces a method handle which will invoke any method handle of the given type, with a given number of trailing arguments replaced by a single trailing Object[] array.

TableSwitch(MethodHandle, MethodHandle[])
ThrowException(Class, Class)

Produces a method handle which will throw exceptions of the given exType.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
TryFinally(MethodHandle, MethodHandle)

Makes a method handle that adapts a target method handle by wrapping it in a try-finally block.

UnregisterFromRuntime() (Inherited from Object)
VarHandleExactInvoker(VarHandle+AccessMode, MethodType)
VarHandleInvoker(VarHandle+AccessMode, MethodType)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WhileLoop(MethodHandle, MethodHandle, MethodHandle)

Constructs a while loop from an initializer, a body, and a predicate.

Zero(Class)

Produces a constant method handle of the requested return type which returns the default value for that type every time it is invoked.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to