public static class JavaConstant.MethodType extends Object implements JavaConstant
java.lang.invoke.MethodType
object.Modifier and Type | Class and Description |
---|---|
protected static interface |
JavaConstant.MethodType.Dispatcher
A dispatcher for extracting information from a
java.lang.invoke.MethodType instance. |
JavaConstant.Dynamic, JavaConstant.MethodHandle, JavaConstant.MethodType, JavaConstant.Simple<T>, JavaConstant.Visitor<T>
Modifier | Constructor and Description |
---|---|
protected |
MethodType(TypeDescription returnType,
List<? extends TypeDescription> parameterTypes)
Creates a method type for the given types.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
accept(JavaConstant.Visitor<T> visitor)
Applies the supplied visitor to this constant type with its respective callback.
|
boolean |
equals(Object other) |
String |
getDescriptor()
Returns the method descriptor of this method type representation.
|
TypeList |
getParameterTypes()
Returns the parameter types of this method type.
|
TypeDescription |
getReturnType()
Returns the return type of this method type.
|
TypeDescription |
getTypeDescription()
Returns a description of the type of this constant.
|
int |
hashCode() |
static JavaConstant.MethodType |
of(Class<?> returnType,
Class<?>... parameterType)
Returns a method type description of the given return type and parameter types.
|
static JavaConstant.MethodType |
of(Constructor<?> constructor)
Returns a method type description of the given constructor.
|
static JavaConstant.MethodType |
of(Method method)
Returns a method type description of the given method.
|
static JavaConstant.MethodType |
of(MethodDescription methodDescription)
Returns a method type description of the given method.
|
static JavaConstant.MethodType |
of(TypeDescription returnType,
List<? extends TypeDescription> parameterTypes)
Returns a method type description of the given return type and parameter types.
|
static JavaConstant.MethodType |
of(TypeDescription returnType,
TypeDescription... parameterType)
Returns a method type description of the given return type and parameter types.
|
static JavaConstant.MethodType |
ofAsm(TypePool typePool,
Type methodType)
Resolves an ASM
Type of sort Type.METHOD . |
static JavaConstant.MethodType |
ofConstant(Class<?> type)
Returns a method type for the given constant type.
|
static JavaConstant.MethodType |
ofConstant(Object instance)
Returns a method type for the given constant.
|
static JavaConstant.MethodType |
ofConstant(TypeDescription typeDescription)
Returns a method type for the given constant type.
|
static JavaConstant.MethodType |
ofGetter(Field field)
Returns a method type for a getter of the given field.
|
static JavaConstant.MethodType |
ofGetter(FieldDescription fieldDescription)
Returns a method type for a getter of the given field.
|
static JavaConstant.MethodType |
ofLoaded(Object methodType)
Returns a method type representation of a loaded
MethodType object. |
static JavaConstant.MethodType |
ofSetter(Field field)
Returns a method type for a setter of the given field.
|
static JavaConstant.MethodType |
ofSetter(FieldDescription fieldDescription)
Returns a method type for a setter of the given field.
|
static JavaConstant.MethodType |
ofSignature(Constructor<?> constructor)
Returns a method type description of the given constructor's signature without considering the constructor's
actual stack consumption and production.
|
static JavaConstant.MethodType |
ofSignature(Method method)
Returns a method type description of the given method's signature without considering the method's actual stack consumption
and production.
|
static JavaConstant.MethodType |
ofSignature(MethodDescription methodDescription)
Returns a method type description of the given method's signature without considering the method's actual stack consumption
and production.
|
Object |
toDescription()
Returns this constant as a Java
java.lang.constant.ConstantDesc if the current VM is of at least version 12. |
StackManipulation |
toStackManipulation()
Returns a stack manipulation loading this value.
|
String |
toString() |
protected MethodType(TypeDescription returnType, List<? extends TypeDescription> parameterTypes)
returnType
- The return type of the method type.parameterTypes
- The parameter types of the method type.public static JavaConstant.MethodType ofAsm(TypePool typePool, Type methodType)
Type
of sort Type.METHOD
.typePool
- The type pool to resolve type descriptions with.methodType
- The ASM method Type
to resolve.JavaConstant.MethodType
.public static JavaConstant.MethodType ofLoaded(Object methodType)
MethodType
object.methodType
- A method type object to represent as a JavaConstant
.JavaConstant.MethodType
.public static JavaConstant.MethodType of(Class<?> returnType, Class<?>... parameterType)
returnType
- The return type to represent.parameterType
- The parameter types to represent.public static JavaConstant.MethodType of(TypeDescription returnType, TypeDescription... parameterType)
returnType
- The return type to represent.parameterType
- The parameter types to represent.public static JavaConstant.MethodType of(TypeDescription returnType, List<? extends TypeDescription> parameterTypes)
returnType
- The return type to represent.parameterTypes
- The parameter types to represent.public static JavaConstant.MethodType of(Method method)
method
- The method to extract the method type from.public static JavaConstant.MethodType of(Constructor<?> constructor)
constructor
- The constructor to extract the method type from.public static JavaConstant.MethodType of(MethodDescription methodDescription)
methodDescription
- The method to extract the method type from.public static JavaConstant.MethodType ofSignature(Method method)
method
- The method to extract the method type from.public static JavaConstant.MethodType ofSignature(Constructor<?> constructor)
constructor
- The constructor to extract the method type from.public static JavaConstant.MethodType ofSignature(MethodDescription methodDescription)
methodDescription
- The method to extract the method type from.public static JavaConstant.MethodType ofSetter(Field field)
field
- The field to extract a setter type for.public static JavaConstant.MethodType ofSetter(FieldDescription fieldDescription)
fieldDescription
- The field to extract a setter type for.public static JavaConstant.MethodType ofGetter(Field field)
field
- The field to extract a getter type for.public static JavaConstant.MethodType ofGetter(FieldDescription fieldDescription)
fieldDescription
- The field to extract a getter type for.public static JavaConstant.MethodType ofConstant(Object instance)
instance
- The constant for which a constant method type should be created.public static JavaConstant.MethodType ofConstant(Class<?> type)
type
- The constant type for which a constant method type should be created.public static JavaConstant.MethodType ofConstant(TypeDescription typeDescription)
typeDescription
- The constant type for which a constant method type should be created.public TypeDescription getReturnType()
public TypeList getParameterTypes()
public String getDescriptor()
public Object toDescription()
java.lang.constant.ConstantDesc
if the current VM is of at least version 12.
If the current VM is of an older version and does not support the type, an exception is thrown.toDescription
in interface JavaConstant
java.lang.constant.ConstantDesc
.public <T> T accept(JavaConstant.Visitor<T> visitor)
accept
in interface JavaConstant
T
- The type of the value that is returned by the visitor.visitor
- The visitor to dispatch.public TypeDescription getTypeDescription()
getTypeDescription
in interface ConstantValue
public StackManipulation toStackManipulation()
toStackManipulation
in interface ConstantValue
public boolean equals(@MaybeNull Object other)
Copyright © 2014–2025. All rights reserved.