Top Description Fields Constructors Methods
net.bytebuddy.jar.asm

public final Class Type

extends Object
Class Inheritance
Imports
java.lang.reflect.Constructor, .Method

A Java field or method type. This class can be used to make it easier to manipulate type and method descriptors.
Authors
Eric Bruneton, Chris Nokleberg

Field Summary

Modifier and TypeField and Description
public static final int
ARRAY

The sort of array reference types.

public static final int
BOOLEAN

The sort of the boolean type.

public static final Type
BOOLEAN_TYPE

The boolean type.

public static final int
BYTE

The sort of the byte type.

public static final Type
BYTE_TYPE

The byte type.

public static final int
CHAR

The sort of the char type.

public static final Type
CHAR_TYPE

The char type.

public static final int
DOUBLE

The sort of the double type.

public static final Type
DOUBLE_TYPE

The double type.

public static final int
FLOAT

The sort of the float type.

public static final Type
FLOAT_TYPE

The float type.

public static final int
INT

The sort of the int type.

public static final Type
INT_TYPE

The int type.

private static final int
INTERNAL

The (private) sort of object reference types represented with an internal name.

public static final int
LONG

The sort of the long type.

public static final Type
LONG_TYPE

The long type.

public static final int
METHOD

The sort of method types.

public static final int
OBJECT

The sort of object reference types.

private static final String
PRIMITIVE_DESCRIPTORS

The descriptors of the primitive types.

public static final int
SHORT

The sort of the short type.

public static final Type
SHORT_TYPE

The short type.

private final int
sort

The sort of this type.

private final int
valueBegin

The beginning index, inclusive, of the value of this Java field or method type in valueBuffer.

private final String
valueBuffer

A buffer containing the value of this field or method type.

private final int
valueEnd

The end index, exclusive, of the value of this Java field or method type in valueBuffer.

public static final int
VOID

The sort of the void type.

public static final Type
VOID_TYPE

The void type.

Constructor Summary

AccessConstructor and Description
private
Type(final int
the sort of this type, see sort.
sort
,
final String
a buffer containing the value of this field or method type.
valueBuffer
,
final int
the beginning index, inclusive, of the value of this field or method type in valueBuffer.
valueBegin
,
final int
the end index, exclusive, of the value of this field or method type in valueBuffer.
valueEnd
)

Constructs a reference type.

Method Summary

Modifier and TypeMethod and Description
private void
appendDescriptor(final StringBuilder
the string builder to which the descriptor must be appended.
stringBuilder
)

Appends the descriptor corresponding to this type to the given string buffer.

private static void
appendDescriptor(final Class<?>
the class whose descriptor must be computed.
clazz
,
final StringBuilder
the string builder to which the descriptor must be appended.
stringBuilder
)

Appends the descriptor of the given class to the given string builder.

public boolean

Returns:

true if the given object is equal to this type.
equals
(final Object
the object to be compared to this type.
object
)

Overrides java.lang.Object.equals.

Tests if the given object is equal to this type.
public int

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 of this method type.

public static int

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.
getArgumentCount
(final String
a method descriptor.
methodDescriptor
)

Returns the number of arguments in the given method descriptor.

public int

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 to i >> 2, and returnSize to i & 0x03). Long and double values have size 2, the others have size 1.
getArgumentsAndReturnSizes
()

Returns the size of the arguments and of the return value of methods of this type.

public static int

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 to i >> 2, and returnSize to i & 0x03). Long and double values have size 2, the others have size 1.
getArgumentsAndReturnSizes
(final String
a method descriptor.
methodDescriptor
)

Computes the size of the arguments and of the return value of a method.

public Type[]

Returns:

the argument types of methods of this type.
getArgumentTypes
()

Returns the argument types of methods of this type.

public static Type[]

Returns:

the Type values corresponding to the argument types of the given method descriptor.
getArgumentTypes
(final String
a method descriptor.
methodDescriptor
)

Returns the Type values corresponding to the argument types of the given method descriptor.

public static Type[]

Returns:

the Type values corresponding to the argument types of the given method.
getArgumentTypes
(final Method
a method.
method
)

Returns the Type values corresponding to the argument types of the given method.

public String

Returns:

the binary name of the class corresponding to this type.
getClassName
()

Returns the binary name of the class corresponding to this type.

public static String

Returns:

the descriptor of the given constructor.
getConstructorDescriptor
(final Constructor<?>
a Constructor object.
constructor
)

Returns the descriptor corresponding to the given constructor.

public String

Returns:

the descriptor corresponding to this type.
getDescriptor
()

Returns the descriptor corresponding to this type.

public static String

Returns:

the descriptor corresponding to the given class.
getDescriptor
(final Class<?>
an object class, a primitive class or an array class.
clazz
)

Returns the descriptor corresponding to the given class.

public int

Returns:

the number of dimensions of this array type.
getDimensions
()

Returns the number of dimensions of this array type.

public Type

Returns:

Returns the type of the elements of this array type.
getElementType
()

Returns the type of the elements of this array type.

public String

Returns:

the internal name of the class corresponding to this object type.
getInternalName
()

Returns the internal name of the class corresponding to this object or array type.

public static String

Returns:

the internal name of the given class.
getInternalName
(final Class<?>
an object or array class.
clazz
)

Returns the internal name of the given class.

public static String

Returns:

the descriptor corresponding to the given argument and return types.
getMethodDescriptor
(final Type
the return type of the method.
returnType
,
final Type...
the argument types of the method.
argumentTypes
)

Returns the descriptor corresponding to the given argument and return types.

public static String

Returns:

the descriptor of the given method.
getMethodDescriptor
(final Method
a Method object.
method
)

Returns the descriptor corresponding to the given method.

public static Type

Returns:

the Type corresponding to the given method descriptor.
getMethodType
(final String
a method descriptor.
methodDescriptor
)

Returns the Type corresponding to the given method descriptor.

public static Type

Returns:

the method Type corresponding to the given argument and return types.
getMethodType
(final Type
the return type of the method.
returnType
,
final Type...
the argument types of the method.
argumentTypes
)

Returns the method Type corresponding to the given argument and return types.

public static Type

Returns:

the Type corresponding to the given internal name.
getObjectType
(final String
an internal name (see Type#getInternalName()).
internalName
)

Returns the Type corresponding to the given internal name.

public int

Returns:

an opcode that is similar to the given opcode, but adapted to this Type. For example, if this type is float and opcode is IRETURN, this method returns FRETURN.
getOpcode
(final int
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.
opcode
)

Returns a JVM instruction opcode adapted to this Type.

public Type

Returns:

the return type of methods of this type.
getReturnType
()

Returns the return type of methods of this type.

public static Type

Returns:

the Type corresponding to the return type of the given method descriptor.
getReturnType
(final String
a method descriptor.
methodDescriptor
)

Returns the Type corresponding to the return type of the given method descriptor.

public static Type

Returns:

the Type corresponding to the return type of the given method.
getReturnType
(final Method
a method.
method
)

Returns the Type corresponding to the return type of the given method.

pack-priv static int

Returns:

the start index of the return type of the given method descriptor.
getReturnTypeOffset
(final String
a method descriptor.
methodDescriptor
)

Returns the start index of the return type of the given method descriptor.

public int

Returns:

the size of values of this type, i.e., 2 for long and double, 0 for void and 1 otherwise.
getSize
()

Returns the size of values of this type.

public int
getSort()

Returns the sort of this type.

public static Type

Returns:

the Type corresponding to the given type descriptor.
getType
(final String
a field or method type descriptor.
typeDescriptor
)

Returns the Type corresponding to the given type descriptor.

public static Type

Returns:

the Type corresponding to the given class.
getType
(final Class<?>
a class.
clazz
)

Returns the Type corresponding to the given class.

public static Type

Returns:

the method Type corresponding to the given constructor.
getType
(final Constructor<?>
a Constructor object.
constructor
)

Returns the method Type corresponding to the given constructor.

public static Type

Returns:

the method Type corresponding to the given method.
getType
(final Method
a Method object.
method
)

Returns the method Type corresponding to the given method.

private static Type

Returns:

the Type corresponding to the given type descriptor.
getTypeInternal
(final String
a buffer containing the field or method descriptor.
descriptorBuffer
,
final int
the beginning index, inclusive, of the field or method descriptor in descriptorBuffer.
descriptorBegin
,
final int
the end index, exclusive, of the field or method descriptor in descriptorBuffer.
descriptorEnd
)

Returns the Type corresponding to the given field or method descriptor.

public int

Returns:

a hash code value for this type.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this type.
public String

Returns:

the descriptor of this type.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this type.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

ARRAYback to summary
public static final int ARRAY

The sort of array reference types. See getSort.

BOOLEANback to summary
public static final int BOOLEAN

The sort of the boolean type. See getSort.

BOOLEAN_TYPEback to summary
public static final Type BOOLEAN_TYPE

The boolean type.

BYTEback to summary
public static final int BYTE

The sort of the byte type. See getSort.

BYTE_TYPEback to summary
public static final Type BYTE_TYPE

The byte type.

CHARback to summary
public static final int CHAR

The sort of the char type. See getSort.

CHAR_TYPEback to summary
public static final Type CHAR_TYPE

The char type.

DOUBLEback to summary
public static final int DOUBLE

The sort of the double type. See getSort.

DOUBLE_TYPEback to summary
public static final Type DOUBLE_TYPE

The double type.

FLOATback to summary
public static final int FLOAT

The sort of the float type. See getSort.

FLOAT_TYPEback to summary
public static final Type FLOAT_TYPE

The float type.

INTback to summary
public static final int INT

The sort of the int type. See getSort.

INT_TYPEback to summary
public static final Type INT_TYPE

The int type.

INTERNALback to summary
private static final int INTERNAL

The (private) sort of object reference types represented with an internal name.

LONGback to summary
public static final int LONG

The sort of the long type. See getSort.

LONG_TYPEback to summary
public static final Type LONG_TYPE

The long type.

METHODback to summary
public static final int METHOD

The sort of method types. See getSort.

OBJECTback to summary
public static final int OBJECT

The sort of object reference types. See getSort.

PRIMITIVE_DESCRIPTORSback to summary
private static final String PRIMITIVE_DESCRIPTORS

The descriptors of the primitive types.

SHORTback to summary
public static final int SHORT

The sort of the short type. See getSort.

SHORT_TYPEback to summary
public static final Type SHORT_TYPE

The short type.

sortback to summary
private final int sort

The sort of this type. Either VOID, BOOLEAN, CHAR, BYTE, SHORT, INT, FLOAT, LONG, DOUBLE, ARRAY, OBJECT, METHOD or INTERNAL.

valueBeginback to summary
private final int valueBegin

The beginning index, inclusive, of the value of this Java field or method type in valueBuffer. This value is an internal name for OBJECT and INTERNAL types, and a field or method descriptor in the other cases.

valueBufferback to summary
private final String valueBuffer

A buffer containing the value of this field or method type. This value is an internal name for OBJECT and INTERNAL types, and a field or method descriptor in the other cases.

For OBJECT types, this field also contains the descriptor: the characters in [valueBegin,valueEnd) contain the internal name, and those in [valueBegin - 1, valueEnd + 1) contain the descriptor.

valueEndback to summary
private final int valueEnd

The end index, exclusive, of the value of this Java field or method type in valueBuffer. This value is an internal name for OBJECT and INTERNAL types, and a field or method descriptor in the other cases.

VOIDback to summary
public static final int VOID

The sort of the void type. See getSort.

VOID_TYPEback to summary
public static final Type VOID_TYPE

The void type.

Constructor Detail

Typeback to summary
private Type(final int sort, final String valueBuffer, final int valueBegin, final int valueEnd)

Constructs a reference type.

Parameters
sort:int

the sort of this type, see sort.

valueBuffer:String

a buffer containing the value of this field or method type.

valueBegin:int

the beginning index, inclusive, of the value of this field or method type in valueBuffer.

valueEnd:int

the end index, exclusive, of the value of this field or method type in valueBuffer.

Method Detail

appendDescriptorback to summary
private void appendDescriptor(final StringBuilder stringBuilder)

Appends the descriptor corresponding to this type to the given string buffer.

Parameters
stringBuilder:StringBuilder

the string builder to which the descriptor must be appended.

appendDescriptorback to summary
private static void appendDescriptor(final Class<?> clazz, final StringBuilder stringBuilder)

Appends the descriptor of the given class to the given string builder.

Parameters
clazz:Class<?>

the class whose descriptor must be computed.

stringBuilder:StringBuilder

the string builder to which the descriptor must be appended.

equalsback to summary
public boolean equals(final Object object)

Overrides java.lang.Object.equals.

Tests if the given object is equal to this type.

Parameters
object:Object

the object to be compared to this type.

Returns:boolean

true if the given object is equal to this type.

Annotations
@Override
getArgumentCountback to summary
public int getArgumentCount()

Returns the number of arguments of this method type. This method should only be used for method types.

Returns:int

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.

getArgumentCountback to summary
public static int getArgumentCount(final String methodDescriptor)

Returns the number of arguments in the given method descriptor.

Parameters
methodDescriptor:String

a method descriptor.

Returns:int

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.

getArgumentsAndReturnSizesback to summary
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:int

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 to i >> 2, and returnSize to i & 0x03). Long and double values have size 2, the others have size 1.

getArgumentsAndReturnSizesback to summary
public static int getArgumentsAndReturnSizes(final String methodDescriptor)

Computes the size of the arguments and of the return value of a method.

Parameters
methodDescriptor:String

a method descriptor.

Returns:int

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 to i >> 2, and returnSize to i & 0x03). Long and double values have size 2, the others have size 1.

getArgumentTypesback to summary
public Type[] getArgumentTypes()

Returns the argument types of methods of this type. This method should only be used for method types.

Returns:Type[]

the argument types of methods of this type.

getArgumentTypesback to summary
public static Type[] getArgumentTypes(final String methodDescriptor)

Returns the Type values corresponding to the argument types of the given method descriptor.

Parameters
methodDescriptor:String

a method descriptor.

Returns:Type[]

the Type values corresponding to the argument types of the given method descriptor.

getArgumentTypesback to summary
public static Type[] getArgumentTypes(final Method method)

Returns the Type values corresponding to the argument types of the given method.

Parameters
method:Method

a method.

Returns:Type[]

the Type values corresponding to the argument types of the given method.

getClassNameback to summary
public String getClassName()

Returns the binary name of the class corresponding to this type. This method must not be used on method types.

Returns:String

the binary name of the class corresponding to this type.

getConstructorDescriptorback to summary
public static String getConstructorDescriptor(final Constructor<?> constructor)

Returns the descriptor corresponding to the given constructor.

Parameters
constructor:Constructor<?>

a Constructor object.

Returns:String

the descriptor of the given constructor.

getDescriptorback to summary
public String getDescriptor()

Returns the descriptor corresponding to this type.

Returns:String

the descriptor corresponding to this type.

getDescriptorback to summary
public static String getDescriptor(final Class<?> clazz)

Returns the descriptor corresponding to the given class.

Parameters
clazz:Class<?>

an object class, a primitive class or an array class.

Returns:String

the descriptor corresponding to the given class.

getDimensionsback to summary
public int getDimensions()

Returns the number of dimensions of this array type. This method should only be used for an array type.

Returns:int

the number of dimensions of this array type.

getElementTypeback to summary
public Type getElementType()

Returns the type of the elements of this array type. This method should only be used for an array type.

Returns:Type

Returns the type of the elements of this array type.

getInternalNameback to summary
public String 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:String

the internal name of the class corresponding to this object type.

getInternalNameback to summary
public static String getInternalName(final Class<?> clazz)

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:Class<?>

an object or array class.

Returns:String

the internal name of the given class.

getMethodDescriptorback to summary
public static String getMethodDescriptor(final Type returnType, final Type... argumentTypes)

Returns the descriptor corresponding to the given argument and return types.

Parameters
returnType:Type

the return type of the method.

argumentTypes:Type[]

the argument types of the method.

Returns:String

the descriptor corresponding to the given argument and return types.

getMethodDescriptorback to summary
public static String getMethodDescriptor(final Method method)

Returns the descriptor corresponding to the given method.

Parameters
method:Method

a Method object.

Returns:String

the descriptor of the given method.

getMethodTypeback to summary
public static Type getMethodType(final String methodDescriptor)

Returns the Type corresponding to the given method descriptor. Equivalent to Type.getType(methodDescriptor).

Parameters
methodDescriptor:String

a method descriptor.

Returns:Type

the Type corresponding to the given method descriptor.

getMethodTypeback to summary
public static Type getMethodType(final Type returnType, final Type... argumentTypes)

Returns the method Type corresponding to the given argument and return types.

Parameters
returnType:Type

the return type of the method.

argumentTypes:Type[]

the argument types of the method.

Returns:Type

the method Type corresponding to the given argument and return types.

getObjectTypeback to summary
public static Type getObjectType(final String internalName)

Returns the Type corresponding to the given internal name.

Parameters
internalName:String

an internal name (see Type#getInternalName()).

Returns:Type

the Type corresponding to the given internal name.

getOpcodeback to summary
public int getOpcode(final int opcode)

Returns a JVM instruction opcode adapted to this Type. This method must not be used for method types.

Parameters
opcode:int

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:int

an opcode that is similar to the given opcode, but adapted to this Type. For example, if this type is float and opcode is IRETURN, this method returns FRETURN.

getReturnTypeback to summary
public Type getReturnType()

Returns the return type of methods of this type. This method should only be used for method types.

Returns:Type

the return type of methods of this type.

getReturnTypeback to summary
public static Type getReturnType(final String methodDescriptor)

Returns the Type corresponding to the return type of the given method descriptor.

Parameters
methodDescriptor:String

a method descriptor.

Returns:Type

the Type corresponding to the return type of the given method descriptor.

getReturnTypeback to summary
public static Type getReturnType(final Method method)

Returns the Type corresponding to the return type of the given method.

Parameters
method:Method

a method.

Returns:Type

the Type corresponding to the return type of the given method.

getReturnTypeOffsetback to summary
pack-priv static int getReturnTypeOffset(final String methodDescriptor)

Returns the start index of the return type of the given method descriptor.

Parameters
methodDescriptor:String

a method descriptor.

Returns:int

the start index of the return type of the given method descriptor.

getSizeback to summary
public int getSize()

Returns the size of values of this type. This method must not be used for method types.

Returns:int

the size of values of this type, i.e., 2 for long and double, 0 for void and 1 otherwise.

getSortback to summary
public int getSort()

Returns the sort of this type.

Returns:int

VOID, BOOLEAN, CHAR, BYTE, SHORT, INT, FLOAT, LONG, DOUBLE, ARRAY, OBJECT or METHOD.

getTypeback to summary
public static Type getType(final String typeDescriptor)

Returns the Type corresponding to the given type descriptor.

Parameters
typeDescriptor:String

a field or method type descriptor.

Returns:Type

the Type corresponding to the given type descriptor.

getTypeback to summary
public static Type getType(final Class<?> clazz)

Returns the Type corresponding to the given class.

Parameters
clazz:Class<?>

a class.

Returns:Type

the Type corresponding to the given class.

getTypeback to summary
public static Type getType(final Constructor<?> constructor)

Returns the method Type corresponding to the given constructor.

Parameters
constructor:Constructor<?>

a Constructor object.

Returns:Type

the method Type corresponding to the given constructor.

getTypeback to summary
public static Type getType(final Method method)

Returns the method Type corresponding to the given method.

Parameters
method:Method

a Method object.

Returns:Type

the method Type corresponding to the given method.

getTypeInternalback to summary
private static Type getTypeInternal(final String descriptorBuffer, final int descriptorBegin, final int descriptorEnd)

Returns the Type corresponding to the given field or method descriptor.

Parameters
descriptorBuffer:String

a buffer containing the field or method descriptor.

descriptorBegin:int

the beginning index, inclusive, of the field or method descriptor in descriptorBuffer.

descriptorEnd:int

the end index, exclusive, of the field or method descriptor in descriptorBuffer.

Returns:Type

the Type corresponding to the given type descriptor.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this type.

Returns:int

a hash code value for this type.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this type.

Returns:String

the descriptor of this type.

Annotations
@Override