MethodType Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A method type represents the arguments and return type accepted and returned by a method handle, or the arguments and return type passed and expected by a method handle caller.
[Android.Runtime.Register("java/lang/invoke/MethodType", ApiSince=26, DoNotGenerateAcw=true)]
public sealed class MethodType : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Lang.Invoke.ITypeDescriptor.IOfMethod
[<Android.Runtime.Register("java/lang/invoke/MethodType", ApiSince=26, DoNotGenerateAcw=true)>]
type MethodType = class
inherit Object
interface ISerializable
interface IJavaObject
interface IDisposable
interface IJavaPeerable
interface ITypeDescriptor.IOfMethod
interface ITypeDescriptor
- Inheritance
- Attributes
- Implements
Remarks
A method type represents the arguments and return type accepted and returned by a method handle, or the arguments and return type passed and expected by a method handle caller. Method types must be properly matched between a method handle and all its callers, and the JVM's operations enforce this matching at, specifically during calls to MethodHandle#invokeExact MethodHandle.invokeExact
and MethodHandle#invoke MethodHandle.invoke
, and during execution of invokedynamic
instructions.
The structure is a return type accompanied by any number of parameter types. The types (primitive, void
, and reference) are represented by Class
objects. (For ease of exposition, we treat void
as if it were a type. In fact, it denotes the absence of a return type.)
All instances of MethodType
are immutable. Two instances are completely interchangeable if they compare equal. Equality depends on pairwise correspondence of the return and parameter types and on nothing else.
This type can be created only by factory methods. All factory methods may cache values, though caching is not guaranteed. Some factory methods are static, while others are virtual methods which modify precursor method types, e.g., by changing a selected parameter.
Factory methods which operate on groups of parameter types are systematically presented in two versions, so that both Java arrays and Java lists can be used to work with groups of parameter types. The query methods parameterArray
and parameterList
also provide a choice between arrays and lists.
MethodType
objects are sometimes derived from bytecode instructions such as invokedynamic
, specifically from the type descriptor strings associated with the instructions in a class file's constant pool.
Like classes and strings, method types can also be represented directly in a class file's constant pool as constants. A method type may be loaded by an ldc
instruction which refers to a suitable CONSTANT_MethodType
constant pool entry. The entry refers to a CONSTANT_Utf8
spelling for the descriptor string. (For full details on method type constants, see sections 4.4.8 and 5.4.3.5 of the Java Virtual Machine Specification.)
When the JVM materializes a MethodType
from a descriptor string, all classes named in the descriptor must be accessible, and will be loaded. (But the classes need not be initialized, as is the case with a CONSTANT_Class
.) This loading may occur at any time before the MethodType
object is first derived.
Java documentation for java.lang.invoke.MethodType
.
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.
Properties
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
HasPrimitives |
Reports if this type contains a primitive argument or return value. |
HasWrappers |
Reports if this type contains a wrapper argument or return value. |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
PeerReference | (Inherited from Object) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. (Inherited from Object) |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. (Inherited from Object) |
Methods
AppendParameterTypes(Class[]) |
Finds or creates a method type with additional parameter types. |
AppendParameterTypes(IList<Class>) |
Finds or creates a method type with additional parameter types. |
ChangeParameterType(Int32, Class) |
Finds or creates a method type with a single different parameter type. |
ChangeReturnType(Class) |
Finds or creates a method type with a different return type. |
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
DescriptorString() |
Returns a descriptor string for this method type. |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
DropParameterTypes(Int32, Int32) |
Finds or creates a method type with some parameter types omitted. |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
Erase() |
Erases all reference types to |
FromMethodDescriptorString(String, ClassLoader) |
Finds or creates an instance of a method type, given the spelling of its bytecode descriptor. |
Generic() |
Converts all types, both reference and primitive, to |
GenericMethodType(Int32, Boolean) |
Finds or creates a method type whose components are |
GenericMethodType(Int32) |
Finds or creates a method type whose components are all |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
InsertParameterTypes(Int32, Class[]) |
Finds or creates a method type with additional parameter types. |
InsertParameterTypes(Int32, IList<Class>) |
Finds or creates a method type with additional parameter types. |
InvokeMethodType(Class, Class, Class[]) |
Finds or creates a method type with the given components. |
InvokeMethodType(Class, Class) |
Finds or creates a method type with the given components. |
InvokeMethodType(Class, Class[]) |
Finds or creates an instance of the given method type. |
InvokeMethodType(Class, IList<Class>) |
Finds or creates a method type with the given components. |
InvokeMethodType(Class, MethodType) |
Finds or creates a method type with the given components. |
InvokeMethodType(Class) |
Finds or creates a method type with the given components. |
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) |
LastParameterType() |
Returns the last parameter type of this method type. |
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) |
ParameterArray() |
Presents the parameter types as an array (a convenience method). |
ParameterCount() |
Returns the number of parameter types in this method type. |
ParameterList() |
Presents the parameter types as a list (a convenience method). |
ParameterType(Int32) |
Returns the parameter type at the specified index, within this method type. |
ReturnType() |
Returns the return type of this method type. |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
ToArray<T>() | (Inherited from Object) |
ToMethodDescriptorString() |
Produces a bytecode descriptor representation of the method type. |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (Inherited from Object) |
Unwrap() |
Converts all wrapper types to their corresponding primitive types. |
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) |
Wrap() |
Converts all primitive types to their corresponding wrapper types. |
Explicit Interface Implementations
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |