Package org.springframework.asm
Class Type
java.lang.Object
org.springframework.asm.Type
A Java field or method type. This class can be used to make it easier to manipulate type and
method descriptors.
- Author:
- Eric Bruneton, Chris Nokleberg
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe sort of array reference types.static final intThe sort of thebooleantype.static final TypeThebooleantype.static final intThe sort of thebytetype.static final TypeThebytetype.static final intThe sort of thechartype.static final TypeThechartype.static final intThe sort of thedoubletype.static final TypeThedoubletype.static final intThe sort of thefloattype.static final TypeThefloattype.static final intThe sort of theinttype.static final TypeTheinttype.static final intThe sort of thelongtype.static final TypeThelongtype.static final intThe sort of method types.static final intThe sort of object reference types.static final intThe sort of theshorttype.static final TypeTheshorttype.static final intThe sort of thevoidtype.static final TypeThevoidtype. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests if the given object is equal to this type.intReturns the size of the arguments and of the return value of methods of this type.static intgetArgumentsAndReturnSizes(String methodDescriptor) Computes the size of the arguments and of the return value of a method.Type[]Returns the argument types of methods of this type.static Type[]getArgumentTypes(Method method) Returns theTypevalues corresponding to the argument types of the given method.static Type[]getArgumentTypes(String methodDescriptor) Returns theTypevalues corresponding to the argument types of the given method descriptor.Returns the binary name of the class corresponding to this type.static StringgetConstructorDescriptor(Constructor<?> constructor) Returns the descriptor corresponding to the given constructor.Returns the descriptor corresponding to this type.static StringgetDescriptor(Class<?> clazz) Returns the descriptor corresponding to the given class.intReturns the number of dimensions of this array type.Returns the type of the elements of this array type.Returns the internal name of the class corresponding to this object or array type.static StringgetInternalName(Class<?> clazz) Returns the internal name of the given class.static StringgetMethodDescriptor(Method method) Returns the descriptor corresponding to the given method.static StringgetMethodDescriptor(Type returnType, Type... argumentTypes) Returns the descriptor corresponding to the given argument and return types.static TypegetMethodType(String methodDescriptor) Returns theTypecorresponding to the given method descriptor.static TypegetMethodType(Type returnType, Type... argumentTypes) Returns the methodTypecorresponding to the given argument and return types.static TypegetObjectType(String internalName) Returns theTypecorresponding to the given internal name.intgetOpcode(int opcode) Returns a JVM instruction opcode adapted to thisType.Returns the return type of methods of this type.static TypegetReturnType(Method method) Returns theTypecorresponding to the return type of the given method.static TypegetReturnType(String methodDescriptor) Returns theTypecorresponding to the return type of the given method descriptor.intgetSize()Returns the size of values of this type.intgetSort()Returns the sort of this type.static TypeReturns theTypecorresponding to the given class.static TypegetType(Constructor<?> constructor) Returns the methodTypecorresponding to the given constructor.static TypeReturns the methodTypecorresponding to the given method.static TypeReturns theTypecorresponding to the given type descriptor.inthashCode()Returns a hash code value for this type.toString()Returns a string representation of this type.
-
Field Details
-
VOID
public static final int VOIDThe sort of thevoidtype. SeegetSort().- See Also:
-
BOOLEAN
public static final int BOOLEANThe sort of thebooleantype. SeegetSort().- See Also:
-
CHAR
public static final int CHARThe sort of thechartype. SeegetSort().- See Also:
-
BYTE
public static final int BYTEThe sort of thebytetype. SeegetSort().- See Also:
-
SHORT
public static final int SHORTThe sort of theshorttype. SeegetSort().- See Also:
-
INT
public static final int INTThe sort of theinttype. SeegetSort().- See Also:
-
FLOAT
public static final int FLOATThe sort of thefloattype. SeegetSort().- See Also:
-
LONG
public static final int LONGThe sort of thelongtype. SeegetSort().- See Also:
-
DOUBLE
public static final int DOUBLEThe sort of thedoubletype. SeegetSort().- See Also:
-
ARRAY
public static final int ARRAYThe sort of array reference types. SeegetSort().- See Also:
-
OBJECT
public static final int OBJECTThe sort of object reference types. SeegetSort().- See Also:
-
METHOD
public static final int METHODThe sort of method types. SeegetSort().- See Also:
-
VOID_TYPE
Thevoidtype. -
BOOLEAN_TYPE
Thebooleantype. -
CHAR_TYPE
Thechartype. -
BYTE_TYPE
Thebytetype. -
SHORT_TYPE
Theshorttype. -
INT_TYPE
Theinttype. -
FLOAT_TYPE
Thefloattype. -
LONG_TYPE
Thelongtype. -
DOUBLE_TYPE
Thedoubletype.
-
-
Method Details
-
getType
Returns theTypecorresponding to the given type descriptor.- Parameters:
typeDescriptor- a field or method type descriptor.- Returns:
- the
Typecorresponding to the given type descriptor.
-
getType
Returns theTypecorresponding to the given class.- Parameters:
clazz- a class.- Returns:
- the
Typecorresponding to the given class.
-
getType
Returns the methodTypecorresponding to the given constructor.- Parameters:
constructor- aConstructorobject.- Returns:
- the method
Typecorresponding to the given constructor.
-
getType
Returns the methodTypecorresponding to the given method. -
getElementType
Returns the type of the elements of this array type. This method should only be used for an array type.- Returns:
- Returns the type of the elements of this array type.
-
getObjectType
Returns theTypecorresponding to the given internal name.- Parameters:
internalName- an internal name.- Returns:
- the
Typecorresponding to the given internal name.
-
getMethodType
Returns theTypecorresponding to the given method descriptor. Equivalent toType.getType(methodDescriptor).- Parameters:
methodDescriptor- a method descriptor.- Returns:
- the
Typecorresponding to the given method descriptor.
-
getMethodType
Returns the methodTypecorresponding to the given argument and return types.- Parameters:
returnType- the return type of the method.argumentTypes- the argument types of the method.- Returns:
- the method
Typecorresponding to the given argument and return types.
-
getArgumentTypes
Returns the argument types of methods of this type. This method should only be used for method types.- Returns:
- the argument types of methods of this type.
-
getArgumentTypes
Returns theTypevalues corresponding to the argument types of the given method descriptor.- Parameters:
methodDescriptor- a method descriptor.- Returns:
- the
Typevalues corresponding to the argument types of the given method descriptor.
-
getArgumentTypes
Returns theTypevalues corresponding to the argument types of the given method.- Parameters:
method- a method.- Returns:
- the
Typevalues corresponding to the argument types of the given method.
-
getReturnType
Returns the return type of methods of this type. This method should only be used for method types.- Returns:
- the return type of methods of this type.
-
getReturnType
Returns theTypecorresponding to the return type of the given method descriptor.- Parameters:
methodDescriptor- a method descriptor.- Returns:
- the
Typecorresponding to the return type of the given method descriptor.
-
getReturnType
Returns theTypecorresponding to the return type of the given method.- Parameters:
method- a method.- Returns:
- the
Typecorresponding to the return type of the given method.
-
getClassName
Returns the binary name of the class corresponding to this type. This method must not be used on method types.- Returns:
- the binary name of the class corresponding to this type.
-
getInternalName
Returns the internal name of the class corresponding to this object or array type. The internal name of a class is its fully qualified name (as returned by Class.getName(), where '.' are replaced by '/'). This method should only be used for an object or array type.- Returns:
- the internal name of the class corresponding to this object type.
-
getInternalName
Returns the internal name of the given class. The internal name of a class is its fully qualified name, as returned by Class.getName(), where '.' are replaced by '/'.- Parameters:
clazz- an object or array class.- Returns:
- the internal name of the given class.
-
getDescriptor
Returns the descriptor corresponding to this type.- Returns:
- the descriptor corresponding to this type.
-
getDescriptor
Returns the descriptor corresponding to the given class.- Parameters:
clazz- an object class, a primitive class or an array class.- Returns:
- the descriptor corresponding to the given class.
-
getConstructorDescriptor
Returns the descriptor corresponding to the given constructor.- Parameters:
constructor- aConstructorobject.- Returns:
- the descriptor of the given constructor.
-
getMethodDescriptor
Returns the descriptor corresponding to the given argument and return types.- Parameters:
returnType- the return type of the method.argumentTypes- the argument types of the method.- Returns:
- the descriptor corresponding to the given argument and return types.
-
getMethodDescriptor
Returns the descriptor corresponding to the given method.- Parameters:
method- aMethodobject.- Returns:
- the descriptor of the given method.
-
getSort
public int getSort()Returns the sort of this type. -
getDimensions
public int getDimensions()Returns the number of dimensions of this array type. This method should only be used for an array type.- Returns:
- the number of dimensions of this array type.
-
getSize
public int getSize()Returns the size of values of this type. This method must not be used for method types.- Returns:
- the size of values of this type, i.e., 2 for
longanddouble, 0 forvoidand 1 otherwise.
-
getArgumentsAndReturnSizes
public int getArgumentsAndReturnSizes()Returns the size of the arguments and of the return value of methods of this type. This method should only be used for method types.- Returns:
- the size of the arguments of the method (plus one for the implicit this argument),
argumentsSize, and the size of its return value, returnSize, packed into a single int i =
(argumentsSize << 2) | returnSize(argumentsSize is therefore equal toi >> 2, and returnSize toi & 0x03).
-
getArgumentsAndReturnSizes
Computes the size of the arguments and of the return value of a method.- Parameters:
methodDescriptor- a method descriptor.- Returns:
- the size of the arguments of the method (plus one for the implicit this argument),
argumentsSize, and the size of its return value, returnSize, packed into a single int i =
(argumentsSize << 2) | returnSize(argumentsSize is therefore equal toi >> 2, and returnSize toi & 0x03).
-
getOpcode
public int getOpcode(int opcode) Returns a JVM instruction opcode adapted to thisType. This method must not be used for method types.- Parameters:
opcode- a JVM instruction opcode. This opcode must be one of ILOAD, ISTORE, IALOAD, IASTORE, IADD, ISUB, IMUL, IDIV, IREM, INEG, ISHL, ISHR, IUSHR, IAND, IOR, IXOR and IRETURN.- Returns:
- an opcode that is similar to the given opcode, but adapted to this
Type. For example, if this type isfloatandopcodeis IRETURN, this method returns FRETURN.
-
equals
Tests if the given object is equal to this type. -
hashCode
public int hashCode()Returns a hash code value for this type. -
toString
Returns a string representation of this type.
-