Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/lang/invoke/MethodType#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/lang/invoke/MethodType#inhmethods)

# MethodType


`
public

final

class
MethodType
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/java/io/Serializable,

https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod<https://developer.android.com/reference/java/lang/Class<?>, https://developer.android.com/reference/java/lang/invoke/MethodType>


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.lang.invoke.MethodType |

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/java/lang/invoke/MethodHandle#invokeExact(java.lang.Object[])`
and `https://developer.android.com/reference/java/lang/invoke/MethodHandle#invoke(java.lang.Object[])`, 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 `https://developer.android.com/reference/java/lang/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.

## Summary

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#appendParameterTypes(java.lang.Class<?>[])(https://developer.android.com/reference/java/lang/Class<?> ptypesToInsert) ` Finds or creates a method type with additional parameter types. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#appendParameterTypes(java.util.List<java.lang.Class<?>>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Class<?>> ptypesToInsert) ` Finds or creates a method type with additional parameter types. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#changeParameterType(int,%20java.lang.Class<?>)(int num, https://developer.android.com/reference/java/lang/Class<?> nptype) ` Finds or creates a method type with a single different parameter type. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#changeReturnType(java.lang.Class<?>)(https://developer.android.com/reference/java/lang/Class<?> nrtype) ` Finds or creates a method type with a different return type. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#descriptorString()() ` Returns a descriptor string for this method type. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#dropParameterTypes(int,%20int)(int start, int end) ` Finds or creates a method type with some parameter types omitted. |
| ` boolean` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object x) ` Compares the specified object with this type for equality. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#erase()() ` Erases all reference types to `Object`. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#fromMethodDescriptorString(java.lang.String,%20java.lang.ClassLoader)(https://developer.android.com/reference/java/lang/String descriptor, https://developer.android.com/reference/java/lang/ClassLoader loader) ` Finds or creates an instance of a method type, given the spelling of its bytecode descriptor. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#generic()() ` Converts all types, both reference and primitive, to `Object`. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#genericMethodType(int,%20boolean)(int objectArgCount, boolean finalArray) ` Finds or creates a method type whose components are `Object` with an optional trailing `Object[]` array. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#genericMethodType(int)(int objectArgCount) ` Finds or creates a method type whose components are all `Object`. |
| ` boolean` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#hasPrimitives()() ` Reports if this type contains a primitive argument or return value. |
| ` boolean` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#hasWrappers()() ` Reports if this type contains a wrapper argument or return value. |
| ` int` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#hashCode()() ` Returns the hash code value for this method type. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#insertParameterTypes(int,%20java.lang.Class<?>[])(int num, https://developer.android.com/reference/java/lang/Class<?> ptypesToInsert) ` Finds or creates a method type with additional parameter types. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#insertParameterTypes(int,%20java.util.List<java.lang.Class<?>>)(int num, https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Class<?>> ptypesToInsert) ` Finds or creates a method type with additional parameter types. |
| ` https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#lastParameterType()() ` Returns the last parameter type of this method type. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.invoke.MethodType)(https://developer.android.com/reference/java/lang/Class<?> rtype, https://developer.android.com/reference/java/lang/invoke/MethodType ptypes) ` Finds or creates a method type with the given components. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])(https://developer.android.com/reference/java/lang/Class<?> rtype, https://developer.android.com/reference/java/lang/Class<?> ptypes) ` Finds or creates an instance of the given method type. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>)(https://developer.android.com/reference/java/lang/Class<?> rtype, https://developer.android.com/reference/java/lang/Class<?> ptype0) ` Finds or creates a method type with the given components. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>)(https://developer.android.com/reference/java/lang/Class<?> rtype) ` Finds or creates a method type with the given components. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.util.List<java.lang.Class<?>>)(https://developer.android.com/reference/java/lang/Class<?> rtype, https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Class<?>> ptypes) ` Finds or creates a method type with the given components. |
| ` static https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>,%20java.lang.Class<?>[])(https://developer.android.com/reference/java/lang/Class<?> rtype, https://developer.android.com/reference/java/lang/Class<?> ptype0, https://developer.android.com/reference/java/lang/Class<?> ptypes) ` Finds or creates a method type with the given components. |
| ` https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#parameterArray()() ` Presents the parameter types as an array (a convenience method). |
| ` int` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#parameterCount()() ` Returns the number of parameter types in this method type. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Class<?>>` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#parameterList()() ` Presents the parameter types as a list (a convenience method). |
| ` https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#parameterType(int)(int num) ` Returns the parameter type at the specified index, within this method type. |
| ` https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#returnType()() ` Returns the return type of this method type. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#toMethodDescriptorString()() ` Produces a bytecode descriptor representation of the method type. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#toString()() ` Returns a string representation of the method type, of the form `"(PT0,PT1...)RT"`. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#unwrap()() ` Converts all wrapper types to their corresponding primitive types. |
| ` https://developer.android.com/reference/java/lang/invoke/MethodType` | ` https://developer.android.com/reference/java/lang/invoke/MethodType#wrap()() ` Converts all primitive types to their corresponding wrapper types. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

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


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

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


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

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


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

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


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(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.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(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

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


From interface `

https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod

` `
abstract


M` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#changeParameterType(int,%20F)(int index, F paramType)
`

Return a method descriptor that is identical to this one,
except that a single parameter type has been changed to the specified type.


`
abstract


M` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#changeReturnType(F)(F newReturn)
`

Return a method descriptor that is identical to this one, except that the return
type has been changed to the specified type


`
abstract


M` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#dropParameterTypes(int,%20int)(int start, int end)
`

Return a method descriptor that is identical to this one,
except that a range of parameter types have been removed.


`
abstract


M` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#insertParameterTypes(int,%20F[])(int pos, F... paramTypes)
`

Return a method descriptor that is identical to this one,
except that a range of additional parameter types have been inserted.


`
abstract


F[]` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#parameterArray()()
`

Return an array of field descriptors for the parameter types of the method type
described by this descriptor


`
abstract


int` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#parameterCount()()
`

Return the number of parameters in the method type


`
abstract


https://developer.android.com/reference/java/util/List<F>` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#parameterList()()
`

Return an immutable list of field descriptors for the parameter types of the method type
described by this descriptor


`
abstract


F` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#parameterType(int)(int i)
`

Return a field descriptor describing the requested parameter of the method type
described by this descriptor


`
abstract


F` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor.OfMethod#returnType()()
`

Return a field descriptor describing the return type of the method type described
by this descriptor


From interface `

https://developer.android.com/reference/java/lang/invoke/TypeDescriptor

` `
abstract


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/invoke/TypeDescriptor#descriptorString()()
`

Returns the descriptor string for this `TypeDescriptor` object.


## Public methods

### appendParameterTypes

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType appendParameterTypes (Class...<?> ptypesToInsert)
```

Finds or creates a method type with additional parameter types.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.

<br />

| Parameters ||
|---|---|
| `ptypesToInsert` | `Class`: zero or more new parameter types to insert after the end of the parameter list <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | the same type, except with the selected parameter(s) appended <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any element of `ptypesToInsert` is `void.class` or if the resulting method type would have more than 255 parameter slots |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `ptypesToInsert` or any of its elements is null |

### appendParameterTypes

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType appendParameterTypes (List<Class<?>> ptypesToInsert)
```

Finds or creates a method type with additional parameter types.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.

<br />

| Parameters ||
|---|---|
| `ptypesToInsert` | `List`: zero or more new parameter types to insert after the end of the parameter list <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | the same type, except with the selected parameter(s) appended <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any element of `ptypesToInsert` is `void.class` or if the resulting method type would have more than 255 parameter slots |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `ptypesToInsert` or any of its elements is null |

### changeParameterType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType changeParameterType (int num, 
                Class<?> nptype)
```

Finds or creates a method type with a single different parameter type.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.

<br />

| Parameters ||
|---|---|
| `num` | `int`: the index (zero-based) of the parameter type to change <br /> |
| `nptype` | `Class`: a new parameter type to replace the old one with <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | the same type, except with the selected parameter changed <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `nptype` is `void.class` |
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `num` is not a valid index into `parameterArray()` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `nptype` is null |

### changeReturnType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType changeReturnType (Class<?> nrtype)
```

Finds or creates a method type with a different return type.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.

<br />

| Parameters ||
|---|---|
| `nrtype` | `Class`: a return parameter type to replace the old one with <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | the same type, except with the return type change <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `nrtype` is null |

### descriptorString

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String descriptorString ()
```

Returns a descriptor string for this method type.


If this method type can be [described nominally](https://developer.android.com/reference/java/lang/invoke/MethodType#descriptor),
then the result is a method type descriptor (JVMS {@jvms 4.3.3}).


If this method type cannot be [described nominally](https://developer.android.com/reference/java/lang/invoke/MethodType#descriptor)
and the result is a string of the form:
> `"(<parameter-descriptors>)<return-descriptor>"`
where `<parameter-descriptors>` is the concatenation of the [descriptor string](https://developer.android.com/reference/java/lang/Class#descriptorString()) of all of the parameter types and the [descriptor string](https://developer.android.com/reference/java/lang/Class#descriptorString()) of the return type.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the descriptor string for this method type <br /> |

**See also:**

- [Nominal Descriptor for {@code MethodType}](https://developer.android.com/reference/java/lang/invoke/MethodType#descriptor)

### dropParameterTypes

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType dropParameterTypes (int start, 
                int end)
```

Finds or creates a method type with some parameter types omitted.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.

<br />

| Parameters ||
|---|---|
| `start` | `int`: the index (zero-based) of the first parameter type to remove <br /> |
| `end` | `int`: the index (greater than `start`) of the first parameter type after not to remove <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | the same type, except with the selected parameter(s) removed <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `start` is negative or greater than `parameterCount()` or if `end` is negative or greater than `parameterCount()` or if `start` is greater than `end` |

### equals

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object x)
```

Compares the specified object with this type for equality.
That is, it returns true if and only if the specified object
is also a method type with exactly the same parameters and return type.

<br />

| Parameters ||
|---|---|
| `x` | `Object`: object to compare <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)`

### erase

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType erase ()
```

Erases all reference types to `Object`.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
All primitive types (including `void`) will remain unchanged.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a version of the original type with all reference types replaced <br /> |

### fromMethodDescriptorString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType fromMethodDescriptorString (String descriptor, 
                ClassLoader loader)
```

Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
Any class or interface name embedded in the descriptor string
will be resolved by calling `https://developer.android.com/reference/java/lang/ClassLoader#loadClass(java.lang.String)`
on the given loader (or if it is null, on the system class loader).


Note that it is possible to encounter method types which cannot be
constructed by this method, because their component types are
not all reachable from a common class loader.


This method is included for the benefit of applications that must
generate bytecodes that process method handles and `invokedynamic`.

<br />

| Parameters ||
|---|---|
| `descriptor` | `String`: a bytecode-level type descriptor string "(T...)T" <br /> |
| `loader` | `ClassLoader`: the class loader in which to look up the types <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a method type matching the bytecode-level type descriptor <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the string is not well-formed |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the string is null |
| `https://developer.android.com/reference/java/lang/TypeNotPresentException` | if a named type cannot be found |

### generic

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType generic ()
```

Converts all types, both reference and primitive, to `Object`.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#genericMethodType(int)`.
The expression `type.wrap().erase()` produces the same value
as `type.generic()`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a version of the original type with all types replaced <br /> |

### genericMethodType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType genericMethodType (int objectArgCount, 
                boolean finalArray)
```

Finds or creates a method type whose components are `Object` with an optional trailing `Object[]` array.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
All parameters and the return type will be `Object`,
except the final array parameter if any, which will be `Object[]`.

<br />

| Parameters ||
|---|---|
| `objectArgCount` | `int`: number of parameters (excluding the final array parameter if any) <br /> |
| `finalArray` | `boolean`: whether there will be a trailing array parameter, of type `Object[]` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a generally applicable method type, for all calls of the given fixed argument count and a collected array of further arguments <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `objectArgCount` is negative or greater than 255 (or 254, if `finalArray` is true) |

**See also:**

- `https://developer.android.com/reference/java/lang/invoke/MethodType#genericMethodType(int)`

### genericMethodType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType genericMethodType (int objectArgCount)
```

Finds or creates a method type whose components are all `Object`.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
All parameters and the return type will be Object.

<br />

| Parameters ||
|---|---|
| `objectArgCount` | `int`: number of parameters <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a generally applicable method type, for all calls of the given argument count <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `objectArgCount` is negative or greater than 255 |

**See also:**

- `https://developer.android.com/reference/java/lang/invoke/MethodType#genericMethodType(int,%20boolean)`

### hasPrimitives

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasPrimitives ()
```

Reports if this type contains a primitive argument or return value.
The return type `void` counts as a primitive.

<br />

| Returns ||
|---|---|
| `boolean` | true if any of the types are primitives <br /> |

### hasWrappers

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasWrappers ()
```

Reports if this type contains a wrapper argument or return value.
Wrappers are types which box primitive values, such as `https://developer.android.com/reference/java/lang/Integer`.
The reference type `java.lang.Void` counts as a wrapper,
if it occurs as a return type.

<br />

| Returns ||
|---|---|
| `boolean` | true if any of the types are wrappers <br /> |

### hashCode

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns the hash code value for this method type.
It is defined to be the same as the hashcode of a List
whose elements are the return type followed by the
parameter types.

<br />

| Returns ||
|---|---|
| `int` | the hash code value for this method type <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Object#hashCode()`
- `https://developer.android.com/reference/java/lang/invoke/MethodType#equals(java.lang.Object)`
- `https://developer.android.com/reference/java/util/List#hashCode()`

### insertParameterTypes

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType insertParameterTypes (int num, 
                Class...<?> ptypesToInsert)
```

Finds or creates a method type with additional parameter types.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.

<br />

| Parameters ||
|---|---|
| `num` | `int`: the position (zero-based) of the inserted parameter type(s) <br /> |
| `ptypesToInsert` | `Class`: zero or more new parameter types to insert into the parameter list <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | the same type, except with the selected parameter(s) inserted <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any element of `ptypesToInsert` is `void.class` or if the resulting method type would have more than 255 parameter slots |
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `num` is negative or greater than `parameterCount()` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `ptypesToInsert` or any of its elements is null |

### insertParameterTypes

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType insertParameterTypes (int num, 
                List<Class<?>> ptypesToInsert)
```

Finds or creates a method type with additional parameter types.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.

<br />

| Parameters ||
|---|---|
| `num` | `int`: the position (zero-based) of the inserted parameter type(s) <br /> |
| `ptypesToInsert` | `List`: zero or more new parameter types to insert into the parameter list <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | the same type, except with the selected parameter(s) inserted <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any element of `ptypesToInsert` is `void.class` or if the resulting method type would have more than 255 parameter slots |
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `num` is negative or greater than `parameterCount()` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `ptypesToInsert` or any of its elements is null |

### lastParameterType

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Class<?> lastParameterType ()
```

Returns the last parameter type of this method type.
If this type has no parameters, the sentinel value
`void.class` is returned instead.

<br />

##### API Note:

-
  The sentinel value is chosen so that reflective queries can be
  made directly against the result value.
  The sentinel value cannot be confused with a real parameter,
  since `void` is never acceptable as a parameter type.
  For variable arity invocation modes, the expression
  `https://developer.android.com/reference/java/lang/Class#getComponentType()`
  is useful to query the type of the "varargs" parameter.

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<?>` | the last parameter type if any, else `void.class` <br /> |

### methodType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType methodType (Class<?> rtype, 
                MethodType ptypes)
```

Finds or creates a method type with the given components.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
The resulting method has the same parameter types as `ptypes`,
and the specified return type.

<br />

| Parameters ||
|---|---|
| `rtype` | `Class`: the return type <br /> |
| `ptypes` | `MethodType`: the method type which supplies the parameter types <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a method type with the given components <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `rtype` or `ptypes` is null |

### methodType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType methodType (Class<?> rtype, 
                Class[]<?> ptypes)
```

Finds or creates an instance of the given method type.

<br />

| Parameters ||
|---|---|
| `rtype` | `Class`: the return type <br /> |
| `ptypes` | `Class`: the parameter types <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a method type with the given components <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any element of `ptypes` is `void.class` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `rtype` or `ptypes` or any element of `ptypes` is null |

### methodType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType methodType (Class<?> rtype, 
                Class<?> ptype0)
```

Finds or creates a method type with the given components.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
The resulting method has the single given parameter type.

<br />

| Parameters ||
|---|---|
| `rtype` | `Class`: the return type <br /> |
| `ptype0` | `Class`: the parameter type <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a method type with the given return value and parameter type <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `ptype0` is `void.class` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `rtype` or `ptype0` is null |

### methodType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType methodType (Class<?> rtype)
```

Finds or creates a method type with the given components.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
The resulting method has no parameter types.

<br />

| Parameters ||
|---|---|
| `rtype` | `Class`: the return type <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a method type with the given return value <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `rtype` is null |

### methodType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType methodType (Class<?> rtype, 
                List<Class<?>> ptypes)
```

Finds or creates a method type with the given components.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.

<br />

| Parameters ||
|---|---|
| `rtype` | `Class`: the return type <br /> |
| `ptypes` | `List`: the parameter types <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a method type with the given components <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any element of `ptypes` is `void.class` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `rtype` or `ptypes` or any element of `ptypes` is null |

### methodType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MethodType methodType (Class<?> rtype, 
                Class<?> ptype0, 
                Class...<?> ptypes)
```

Finds or creates a method type with the given components.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
The leading parameter type is prepended to the remaining array.

<br />

| Parameters ||
|---|---|
| `rtype` | `Class`: the return type <br /> |
| `ptype0` | `Class`: the first parameter type <br /> |
| `ptypes` | `Class`: the remaining parameter types <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a method type with the given components <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `ptype0` or `ptypes` or any element of `ptypes` is `void.class` |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `rtype` or `ptype0` or `ptypes` or any element of `ptypes` is null |

### parameterArray

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Class[]<?> parameterArray ()
```

Presents the parameter types as an array (a convenience method).
Changes to the array will not result in changes to the type.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<?>` | the parameter types (as a fresh copy if necessary) <br /> |

### parameterCount

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int parameterCount ()
```

Returns the number of parameter types in this method type.

<br />

| Returns ||
|---|---|
| `int` | the number of parameter types <br /> |

### parameterList

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<Class<?>> parameterList ()
```

Presents the parameter types as a list (a convenience method).
The list will be immutable.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Class<?>>` | the parameter types (as an immutable list) <br /> |

### parameterType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Class<?> parameterType (int num)
```

Returns the parameter type at the specified index, within this method type.

<br />

| Parameters ||
|---|---|
| `num` | `int`: the index (zero-based) of the desired parameter type <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<?>` | the selected parameter type <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException` | if `num` is not a valid index into `parameterArray()` |

### returnType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Class<?> returnType ()
```

Returns the return type of this method type.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<?>` | the return type <br /> |

### toMethodDescriptorString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toMethodDescriptorString ()
```

Produces a bytecode descriptor representation of the method type.


Note that this is not a strict inverse of `https://developer.android.com/reference/java/lang/invoke/MethodType#fromMethodDescriptorString(java.lang.String,%20java.lang.ClassLoader)`.
Two distinct classes which share a common name but have different class loaders
will appear identical when viewed within descriptor strings.


This method is included for the benefit of applications that must
generate bytecodes that process method handles and `invokedynamic`.
`https://developer.android.com/reference/java/lang/invoke/MethodType#fromMethodDescriptorString(java.lang.String,%20java.lang.ClassLoader)`,
because the latter requires a suitable class loader argument.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the bytecode type descriptor representation <br /> |

### toString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the method type,
of the form `"(PT0,PT1...)RT"`.
The string representation of a method type is a
parenthesis enclosed, comma separated list of type names,
followed immediately by the return type.


Each type is represented by its
`https://developer.android.com/reference/java/lang/Class#getSimpleName()`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### unwrap

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType unwrap ()
```

Converts all wrapper types to their corresponding primitive types.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
All primitive types (including `void`) will remain unchanged.
A return type of `java.lang.Void` is changed to `void`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a version of the original type with all wrapper types replaced <br /> |

### wrap

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MethodType wrap ()
```

Converts all primitive types to their corresponding wrapper types.
Convenience method for `https://developer.android.com/reference/java/lang/invoke/MethodType#methodType(java.lang.Class<?>,%20java.lang.Class<?>[])`.
All reference types (including wrapper types) will remain unchanged.
A `void` return type is changed to the type `java.lang.Void`.
The expression `type.wrap().erase()` produces the same value
as `type.generic()`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/invoke/MethodType` | a version of the original type with all primitive types replaced <br /> |