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
Modifier and TypeFieldDescriptionstatic final int
The sort of array reference types.static final int
The sort of theboolean
type.static final Type
Theboolean
type.static final int
The sort of thebyte
type.static final Type
Thebyte
type.static final int
The sort of thechar
type.static final Type
Thechar
type.static final int
The sort of thedouble
type.static final Type
Thedouble
type.static final int
The sort of thefloat
type.static final Type
Thefloat
type.static final int
The sort of theint
type.static final Type
Theint
type.static final int
The sort of thelong
type.static final Type
Thelong
type.static final int
The sort of method types.static final int
The sort of object reference types.static final int
The sort of theshort
type.static final Type
Theshort
type.static final int
The sort of thevoid
type.static final Type
Thevoid
type. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Tests if the given object is equal to this type.int
Returns the number of arguments of this method type.static int
getArgumentCount
(String methodDescriptor) Returns the number of arguments in the given method descriptor.int
Returns the size of the arguments and of the return value of methods of this type.static int
getArgumentsAndReturnSizes
(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 theType
values corresponding to the argument types of the given method.static Type[]
getArgumentTypes
(String methodDescriptor) Returns theType
values corresponding to the argument types of the given method descriptor.Returns the binary name of the class corresponding to this type.static String
getConstructorDescriptor
(Constructor<?> constructor) Returns the descriptor corresponding to the given constructor.Returns the descriptor corresponding to this type.static String
getDescriptor
(Class<?> clazz) Returns the descriptor corresponding to the given class.int
Returns 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 String
getInternalName
(Class<?> clazz) Returns the internal name of the given class.static String
getMethodDescriptor
(Method method) Returns the descriptor corresponding to the given method.static String
getMethodDescriptor
(Type returnType, Type... argumentTypes) Returns the descriptor corresponding to the given argument and return types.static Type
getMethodType
(String methodDescriptor) Returns theType
corresponding to the given method descriptor.static Type
getMethodType
(Type returnType, Type... argumentTypes) Returns the methodType
corresponding to the given argument and return types.static Type
getObjectType
(String internalName) Returns theType
corresponding to the given internal name.int
getOpcode
(int opcode) Returns a JVM instruction opcode adapted to thisType
.Returns the return type of methods of this type.static Type
getReturnType
(Method method) Returns theType
corresponding to the return type of the given method.static Type
getReturnType
(String methodDescriptor) Returns theType
corresponding to the return type of the given method descriptor.int
getSize()
Returns the size of values of this type.int
getSort()
Returns the sort of this type.static Type
Returns theType
corresponding to the given class.static Type
getType
(Constructor<?> constructor) Returns the methodType
corresponding to the given constructor.static Type
Returns the methodType
corresponding to the given method.static Type
Returns theType
corresponding to the given type descriptor.int
hashCode()
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 thevoid
type. SeegetSort()
.- See Also:
-
BOOLEAN
public static final int BOOLEANThe sort of theboolean
type. SeegetSort()
.- See Also:
-
CHAR
public static final int CHARThe sort of thechar
type. SeegetSort()
.- See Also:
-
BYTE
public static final int BYTEThe sort of thebyte
type. SeegetSort()
.- See Also:
-
SHORT
public static final int SHORTThe sort of theshort
type. SeegetSort()
.- See Also:
-
INT
public static final int INTThe sort of theint
type. SeegetSort()
.- See Also:
-
FLOAT
public static final int FLOATThe sort of thefloat
type. SeegetSort()
.- See Also:
-
LONG
public static final int LONGThe sort of thelong
type. SeegetSort()
.- See Also:
-
DOUBLE
public static final int DOUBLEThe sort of thedouble
type. 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
Thevoid
type. -
BOOLEAN_TYPE
Theboolean
type. -
CHAR_TYPE
Thechar
type. -
BYTE_TYPE
Thebyte
type. -
SHORT_TYPE
Theshort
type. -
INT_TYPE
Theint
type. -
FLOAT_TYPE
Thefloat
type. -
LONG_TYPE
Thelong
type. -
DOUBLE_TYPE
Thedouble
type.
-
-
Method Details
-
getType
Returns theType
corresponding to the given type descriptor.- Parameters:
typeDescriptor
- a field or method type descriptor.- Returns:
- the
Type
corresponding to the given type descriptor.
-
getType
Returns theType
corresponding to the given class.- Parameters:
clazz
- a class.- Returns:
- the
Type
corresponding to the given class.
-
getType
Returns the methodType
corresponding to the given constructor.- Parameters:
constructor
- aConstructor
object.- Returns:
- the method
Type
corresponding to the given constructor.
-
getType
Returns the methodType
corresponding 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 theType
corresponding to the given internal name.- Parameters:
internalName
- an internal name (seegetInternalName()
).- Returns:
- the
Type
corresponding to the given internal name.
-
getMethodType
Returns theType
corresponding to the given method descriptor. Equivalent toType.getType(methodDescriptor)
.- Parameters:
methodDescriptor
- a method descriptor.- Returns:
- the
Type
corresponding to the given method descriptor.
-
getMethodType
Returns the methodType
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 method
Type
corresponding 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 theType
values corresponding to the argument types of the given method descriptor.- Parameters:
methodDescriptor
- a method descriptor.- Returns:
- the
Type
values corresponding to the argument types of the given method descriptor.
-
getArgumentTypes
Returns theType
values corresponding to the argument types of the given method.- Parameters:
method
- a method.- Returns:
- the
Type
values 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 theType
corresponding to the return type of the given method descriptor.- Parameters:
methodDescriptor
- a method descriptor.- Returns:
- the
Type
corresponding to the return type of the given method descriptor.
-
getReturnType
Returns theType
corresponding to the return type of the given method.- Parameters:
method
- a method.- Returns:
- the
Type
corresponding 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
- aConstructor
object.- 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
- aMethod
object.- 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
long
anddouble
, 0 forvoid
and 1 otherwise.
-
getArgumentCount
public int getArgumentCount()Returns the number of arguments of this method type. This method should only be used for method types.- Returns:
- the number of arguments of this method type. Each argument counts for 1, even long and double ones. The implicit @literal{this} argument is not counted.
-
getArgumentCount
Returns the number of arguments in the given method descriptor.- Parameters:
methodDescriptor
- a method descriptor.- Returns:
- the number of arguments in the given method descriptor. Each argument counts for 1, even long and double ones. The implicit @literal{this} argument is not counted.
-
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
). Long and double values have size 2, the others have size 1.
-
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
). Long and double values have size 2, the others have size 1.
-
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 isfloat
andopcode
is 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.
-