# TypeDescriptor.OfMethod

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

# OfMethod

```
interface OfMethod<F : TypeDescriptor.OfField<F>!, M : TypeDescriptor.OfMethod<F, M>!> : TypeDescriptor
```

|--------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.invoke.TypeDescriptor.OfMethod](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor.OfMethod#) |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [MethodType](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodType) |------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [MethodType](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodType) | 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. | |

An entity that has a method type descriptor Method descriptors conforming to JVMS {@jvms 4.3.3} can be described

## Summary

|                                                                                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                                                                                    ||
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstractM                                                                                                             | [changeParameterType](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor.OfMethod#changeParameterType(kotlin.Int,%20java.lang.invoke.TypeDescriptor.OfMethod.F))`(`index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `paramType:` `F`)` Return a method descriptor that is identical to this one, except that a single parameter type has been changed to the specified type.                |
| abstractM                                                                                                             | [changeReturnType](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor.OfMethod#changeReturnType(java.lang.invoke.TypeDescriptor.OfMethod.F))`(`newReturn:` `F`)` Return a method descriptor that is identical to this one, except that the return type has been changed to the specified type                                                                                                                                    |
| abstractM                                                                                                             | [dropParameterTypes](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor.OfMethod#dropParameterTypes(kotlin.Int,%20kotlin.Int))`(`start:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `end:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Return a method descriptor that is identical to this one, except that a range of parameter types have been removed. |
| abstractM                                                                                                             | [insertParameterTypes](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor.OfMethod#insertParameterTypes(kotlin.Int,%20java.lang.invoke.TypeDescriptor.OfMethod.F))`(`pos:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `vararg` `paramTypes:` `F`)` Return a method descriptor that is identical to this one, except that a range of additional parameter types have been inserted.            |
| abstract[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<F\>!                          | [parameterArray](https://developer.android.com/reference/kotlin/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://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                    | [parameterCount](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor.OfMethod#parameterCount())`()` Return the number of parameters in the method type                                                                                                                                                                                                                                                                            |
| abstract[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<F\>! | [parameterList](https://developer.android.com/reference/kotlin/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                                                                                                                                                                                                           |
| abstractF                                                                                                             | [parameterType](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor.OfMethod#parameterType(kotlin.Int))`(`i:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Return a field descriptor describing the requested parameter of the method type described by this descriptor                                                                                                                         |
| abstractF                                                                                                             | [returnType](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor.OfMethod#returnType())`()` Return a field descriptor describing the return type of the method type described by this descriptor                                                                                                                                                                                                                                  |

| Inherited functions ||
|---|---|
| From class[TypeDescriptor](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor) |-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [descriptorString](https://developer.android.com/reference/kotlin/java/lang/invoke/TypeDescriptor#descriptorString())`()` <br /> Returns the descriptor string for this`TypeDescriptor`object. If this`TypeDescriptor`object can be described in nominal form, then this method returns a type descriptor as specified in JVMS {@jvms 4.3}. The result descriptor string can be used to produce a`java.lang.constant.ConstantDesc nominal descriptor`. Otherwise, the result string is not a type descriptor. No`java.lang.constant.ConstantDesc nominal descriptor`can be produced from the result string. <br /> | ||

## Public methods

### changeParameterType

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

```
abstract fun changeParameterType(
    index: Int, 
    paramType: F
): M
```

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

|                                                          Parameters                                                          ||
|-------------|-----------------------------------------------------------------------------------------------------------------|
| `index`     | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the index of the parameter to change |
| `paramType` | F:a field descriptor describing the new parameter type                                                          |

|            Return            ||
|---|---------------------------|
| M | the new method descriptor |

|                                                Exceptions                                                 ||
|---------------------------------------|--------------------------------------------------------------------|
| `java.lang.NullPointerException`      | if any argument is`null`                                           |
| `java.lang.IndexOutOfBoundsException` | if the index is outside the half-open range {\[0, parameterCount)} |

### changeReturnType

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

```
abstract fun changeReturnType(newReturn: F): M
```

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

|                        Parameters                         ||
|-------------|----------------------------------------------|
| `newReturn` | F:a field descriptor for the new return type |

|            Return            ||
|---|---------------------------|
| M | the new method descriptor |

|                         Exceptions                         ||
|----------------------------------|--------------------------|
| `java.lang.NullPointerException` | if any argument is`null` |

### dropParameterTypes

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

```
abstract fun dropParameterTypes(
    start: Int, 
    end: Int
): M
```

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

|                                                            Parameters                                                            ||
|---------|-------------------------------------------------------------------------------------------------------------------------|
| `start` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the index of the first parameter to remove   |
| `end`   | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the index after the last parameter to remove |

|            Return            ||
|---|---------------------------|
| M | the new method descriptor |

|                                                                                    Exceptions                                                                                    ||
|---------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.IndexOutOfBoundsException` | if`start`is outside the half-open range`[0, parameterCount)`, or`end`is outside the closed range`[0, parameterCount]`, or if`start > end` |

### insertParameterTypes

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

```
abstract fun insertParameterTypes(
    pos: Int, 
    vararg paramTypes: F
): M
```

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

|                                                                     Parameters                                                                     ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------|
| `pos`        | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the index at which to insert the first inserted parameter |
| `paramTypes` | F:field descriptors describing the new parameter types to insert                                                                     |

|            Return            ||
|---|---------------------------|
| M | the new method descriptor |

|                                            Exceptions                                             ||
|---------------------------------------|------------------------------------------------------------|
| `java.lang.NullPointerException`      | if any argument is`null`                                   |
| `java.lang.IndexOutOfBoundsException` | if`pos`is outside the closed range {\[0, parameterCount\]} |

### parameterArray

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

```
abstract fun parameterArray(): Array<F>!
```

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

|                                                            Return                                                             ||
|------------------------------------------------------------------------------------|-------------------------------------------|
| [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<F>! | field descriptors for the parameter types |

### parameterCount

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

```
abstract fun parameterCount(): Int
```

Return the number of parameters in the method type

|                                                Return                                                ||
|----------------------------------------------------------------------------|--------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the number of parameters |

### parameterList

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

```
abstract fun parameterList(): MutableList<F>!
```

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

|                                                                         Return                                                                         ||
|-------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<F>! | field descriptors for the parameter types |

### parameterType

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

```
abstract fun parameterType(i: Int): F
```

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

|                                                 Parameters                                                 ||
|-----|-------------------------------------------------------------------------------------------------------|
| `i` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the index of the parameter |

|                         Return                         ||
|---|-----------------------------------------------------|
| F | a field descriptor for the requested parameter type |

|                                                Exceptions                                                 ||
|---------------------------------------|--------------------------------------------------------------------|
| `java.lang.IndexOutOfBoundsException` | if the index is outside the half-open range {\[0, parameterCount)} |

### returnType

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

```
abstract fun returnType(): F
```

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

|                  Return                   ||
|---|----------------------------------------|
| F | a field descriptor for the return type |