GeezerVison is showing docs.oracle.com — MethodType (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
- Summary:
- Nested |
- Field |
- Constr |
- Method
- Detail:
- Field |
- Constr |
- Method
compact1, compact2, compact3
java.lang.invoke
Class MethodType
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
MethodType |
appendParameterTypes(Class<?>... ptypesToInsert) |
Finds or creates a method type with additional parameter types.
|
MethodType |
appendParameterTypes(List<Class<?>> ptypesToInsert) |
Finds or creates a method type with additional parameter types.
|
MethodType |
changeParameterType(int num,
Class<?> nptype) |
Finds or creates a method type with a single different parameter type.
|
MethodType |
changeReturnType(Class<?> nrtype) |
Finds or creates a method type with a different return type.
|
MethodType |
dropParameterTypes(int start,
int end) |
Finds or creates a method type with some parameter types omitted.
|
boolean |
equals(Object x) |
Compares the specified object with this type for equality.
|
MethodType |
erase() |
Erases all reference types to Object.
|
static MethodType |
fromMethodDescriptorString(String descriptor,
ClassLoader loader) |
Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
|
MethodType |
generic() |
Converts all types, both reference and primitive, to Object.
|
static MethodType |
genericMethodType(int objectArgCount) |
Finds or creates a method type whose components are all Object.
|
static MethodType |
genericMethodType(int objectArgCount,
boolean finalArray) |
Finds or creates a method type whose components are Object with an optional trailing Object[] array.
|
int |
hashCode() |
Returns the hash code value for this method type.
|
boolean |
hasPrimitives() |
Reports if this type contains a primitive argument or return value.
|
boolean |
hasWrappers() |
Reports if this type contains a wrapper argument or return value.
|
MethodType |
insertParameterTypes(int num,
Class<?>... ptypesToInsert) |
Finds or creates a method type with additional parameter types.
|
MethodType |
insertParameterTypes(int num,
List<Class<?>> ptypesToInsert) |
Finds or creates a method type with additional parameter types.
|
static MethodType |
methodType(Class<?> rtype) |
Finds or creates a method type with the given components.
|
static MethodType |
methodType(Class<?> rtype,
Class<?> ptype0) |
Finds or creates a method type with the given components.
|
static MethodType |
methodType(Class<?> rtype,
Class<?>[] ptypes) |
Finds or creates an instance of the given method type.
|
static MethodType |
methodType(Class<?> rtype,
Class<?> ptype0,
Class<?>... ptypes) |
Finds or creates a method type with the given components.
|
static MethodType |
methodType(Class<?> rtype,
List<Class<?>> ptypes) |
Finds or creates a method type with the given components.
|
static MethodType |
methodType(Class<?> rtype,
MethodType ptypes) |
Finds or creates a method type with the given components.
|
Class<?>[] |
parameterArray() |
Presents the parameter types as an array (a convenience method).
|
int |
parameterCount() |
Returns the number of parameter types in this method type.
|
List<Class<?>> |
parameterList() |
Presents the parameter types as a list (a convenience method).
|
Class<?> |
parameterType(int num) |
Returns the parameter type at the specified index, within this method type.
|
Class<?> |
returnType() |
Returns the return type of this method type.
|
String |
toMethodDescriptorString() |
Produces a bytecode descriptor representation of the method type.
|
String |
toString() |
Returns a string representation of the method type,
of the form "(PT0,PT1...)RT".
|
MethodType |
unwrap() |
Converts all wrapper types to their corresponding primitive types.
|
MethodType |
wrap() |
Converts all primitive types to their corresponding wrapper types.
|
-
-
Method Detail
-
methodType
public static MethodType methodType(Class<?> rtype,
Class<?>[] ptypes)
Finds or creates an instance of the given method type.
- Parameters:
rtype - the return type
ptypes - the parameter types
- Returns:
- a method type with the given components
- Throws:
NullPointerException - if rtype or ptypes or any element of ptypes is null
IllegalArgumentException - if any element of ptypes is void.class
-
wrap
public MethodType wrap()
Converts all primitive types to their corresponding wrapper types.
Convenience method for methodType.
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().
- Returns:
- a version of the original type with all primitive types replaced
-
parameterType
public Class<?> parameterType(int num)
Returns the parameter type at the specified index, within this method type.
- Parameters:
num - the index (zero-based) of the desired parameter type
- Returns:
- the selected parameter type
- Throws:
IndexOutOfBoundsException - if num is not a valid index into parameterArray()
-
equals
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.
- Overrides:
equals in class Object
- Parameters:
x - object to compare
- Returns:
true if this object is the same as the obj
argument; false otherwise.
- See Also:
Object.equals(Object)
-
toString
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
simple name.
- Overrides:
toString in class Object
- Returns:
- a string representation of the object.
Java™ Platform Standard Ed. 8
- Summary:
- Nested |
- Field |
- Constr |
- Method
- Detail:
- Field |
- Constr |
- Method
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|