类 Type
java.lang.Object
cn.taketoday.bytecode.Type
A Java field or method type. This class can be used to make it easier to manipulate type and
method descriptors.
- 作者:
- Eric Bruneton, Chris Nokleberg
-
字段概要
字段修饰符和类型字段说明static 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 Type[]static final intThe sort of thefloattype.static final TypeThefloattype.static final intThe sort of theinttype.static final TypeTheinttype.private static final intThe (private) sort of object reference types represented with an internal name.static final intThe sort of thelongtype.static final TypeThelongtype.static final intThe sort of method types.static final intThe sort of object reference types.private static final StringThe descriptors of the primitive types.The descriptors of the primitive Java types (plus void).static final intThe sort of theshorttype.static final TypeTheshorttype.private final intThe sort of this type.static final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final TypeThe type of the java.lang.Object class.static final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typestatic final Typeprivate final intThe beginning index, inclusive, of the value of this Java field or method type invalueBuffer.private final StringA buffer containing the value of this field or method type.private final intThe end index, exclusive, of the value of this Java field or method type invalueBuffer.static final intThe sort of thevoidtype.static final TypeThevoidtype. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static Type[]static Type[]static Type[]private static voidappendDescriptor(Class<?> clazz, StringBuilder stringBuilder) Appends the descriptor of the given class to the given string builder.private voidappendDescriptor(StringBuilder stringBuilder) Appends the descriptor corresponding to this type to the given string buffer.static Type[]ToTypearraybooleanTests if the given object is equal to this type.static TypeforReturnType(Method method) Returns theTypecorresponding to the return type of the given method.static TypeforReturnType(String methodDescriptor) Returns theTypecorresponding to the return type of the given method descriptor.static TypeReturns theTypecorresponding to the given class.static TypefromConstructor(Constructor<?> constructor) Returns the methodTypecorresponding to the given constructor.static TypefromDescriptor(String typeDescriptor) Returns theTypecorresponding to the given type descriptor.static TypefromInternalName(String internalName) Returns theTypecorresponding to the given internal name.static Type[]fromInternalNames(String[] names) static TypefromMethod(Type returnType, Type... argumentTypes) Returns the methodTypecorresponding to the given argument and return types.static TypefromMethod(Method method) Returns the methodTypecorresponding to the given method.static TypefromMethod(String methodDescriptor) Returns theTypecorresponding to the given method descriptor.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.get Boxed TypeReturns 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.static StringgetDescriptor(String parameterTypes) Object -> Ljava/lang/Object; Object, Object ,Class -> Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Class;static StringgetDescriptor(String type, boolean defaultPackage) Returns the descriptor corresponding to the given type name.static StringgetDescriptor(String parameterTypes, int startIdx, int endIdx, boolean defaultPackage) Object -> Ljava/lang/Object; Object, Object ,Class -> Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Class;intReturns the number of dimensions of this array type.Returns the type of the elements of this array type.static Type[]getExceptionTypes(Member member) 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(Type returnType, Type... argumentTypes) Returns the descriptor corresponding to the given argument and return types.static StringgetMethodDescriptor(Method method) Returns the descriptor corresponding to the given method.static Type[]getObjectTypes(String[] internalNames) Returns theTypes corresponding 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 intgetReturnTypeOffset(String methodDescriptor) Returns the start index of 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 intgetStackSize(Type[] types) private static TypegetTypeInternal(String descriptorBuffer, int descriptorBegin, int descriptorEnd) Returns theTypecorresponding to the given field or method descriptor.static Type[]static Type[]inthashCode()Returns a hash code value for this type.booleanisArray()Determines if thisTypeobject represents an array class.booleanDetermines if the specifiedTypeobject represents a primitive type.static Typestatic Stringstatic String[]toInternalNames(Type... types) toString()Returns a string representation of this type.
-
字段详细资料
-
VOID
public static final int VOIDThe sort of thevoidtype. SeegetSort().- 另请参阅:
-
BOOLEAN
public static final int BOOLEANThe sort of thebooleantype. SeegetSort().- 另请参阅:
-
CHAR
public static final int CHARThe sort of thechartype. SeegetSort().- 另请参阅:
-
BYTE
public static final int BYTEThe sort of thebytetype. SeegetSort().- 另请参阅:
-
SHORT
public static final int SHORTThe sort of theshorttype. SeegetSort().- 另请参阅:
-
INT
public static final int INTThe sort of theinttype. SeegetSort().- 另请参阅:
-
FLOAT
public static final int FLOATThe sort of thefloattype. SeegetSort().- 另请参阅:
-
LONG
public static final int LONGThe sort of thelongtype. SeegetSort().- 另请参阅:
-
DOUBLE
public static final int DOUBLEThe sort of thedoubletype. SeegetSort().- 另请参阅:
-
ARRAY
public static final int ARRAYThe sort of array reference types. SeegetSort().- 另请参阅:
-
OBJECT
public static final int OBJECTThe sort of object reference types. SeegetSort().- 另请参阅:
-
METHOD
public static final int METHODThe sort of method types. SeegetSort().- 另请参阅:
-
INTERNAL
private static final int INTERNALThe (private) sort of object reference types represented with an internal name.- 另请参阅:
-
PRIMITIVE_DESCRIPTORS
The descriptors of the primitive types.- 另请参阅:
-
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. -
PRIMITIVE_TYPE_DESCRIPTORS
The descriptors of the primitive Java types (plus void). -
TYPE_TYPE
-
TYPE_CONSTANT
-
TYPE_OBJECT_ARRAY
-
TYPE_CLASS_ARRAY
-
TYPE_STRING_ARRAY
-
TYPE_ERROR
-
TYPE_SYSTEM
-
TYPE_LONG
-
TYPE_BYTE
-
TYPE_CLASS
-
TYPE_FLOAT
-
TYPE_SHORT
-
TYPE_DOUBLE
-
TYPE_STRING
-
TYPE_NUMBER
-
TYPE_BOOLEAN
-
TYPE_INTEGER
-
TYPE_CHARACTER
-
TYPE_THROWABLE
-
TYPE_CLASS_LOADER
-
TYPE_STRING_BUFFER
-
TYPE_RUNTIME_EXCEPTION
-
TYPE_SIGNATURE
-
TYPE_OBJECT
The type of the java.lang.Object class. -
EMPTY_ARRAY
-
sort
private final int sort -
valueBuffer
A buffer containing the value of this field or method type. This value is an internal name forOBJECTandINTERNALtypes, and a field or method descriptor in the other cases.For
OBJECTtypes, 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. -
valueBegin
private final int valueBeginThe beginning index, inclusive, of the value of this Java field or method type invalueBuffer. This value is an internal name forOBJECTandINTERNALtypes, and a field or method descriptor in the other cases. -
valueEnd
private final int valueEndThe end index, exclusive, of the value of this Java field or method type invalueBuffer. This value is an internal name forOBJECTandINTERNALtypes, and a field or method descriptor in the other cases.
-
-
构造器详细资料
-
Type
Constructs a reference type.- 参数:
sort- the sort of this type, seesort.valueBuffer- a buffer containing the value of this field or method type.valueBegin- the beginning index, inclusive, of the value of this field or method type in valueBuffer.valueEnd- the end index, exclusive, of the value of this field or method type in valueBuffer.
-
-
方法详细资料
-
parse
- 从以下版本开始:
- 4.0
-
resolvePrimitiveTypeDescriptor
- 从以下版本开始:
- 4.0
-
fromDescriptor
Returns theTypecorresponding to the given type descriptor.- 参数:
typeDescriptor- a field or method type descriptor.- 返回:
- the
Typecorresponding to the given type descriptor.
-
fromClass
Returns theTypecorresponding to the given class.- 参数:
clazz- a class.- 返回:
- the
Typecorresponding to the given class.
-
fromConstructor
Returns the methodTypecorresponding to the given constructor.- 参数:
constructor- aConstructorobject.- 返回:
- the method
Typecorresponding to the given constructor.
-
fromMethod
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 the type of the elements of this array type.
-
fromInternalName
Returns theTypecorresponding to the given internal name.- 参数:
internalName- an internal name.- 返回:
- the
Typecorresponding to the given internal name.
-
fromInternalNames
- 从以下版本开始:
- 4.0
-
getObjectTypes
Returns theTypes corresponding to the given internal name.- 参数:
internalNames- internal name. if null returns null- 返回:
- the
Types corresponding to the given internal name.
-
getExceptionTypes
- 参数:
member- Member- 返回:
- the
Types corresponding to the given Executable's ExceptionTypes. - 抛出:
IllegalArgumentException- not a Executable- 从以下版本开始:
- 4.0
- 另请参阅:
-
fromMethod
Returns theTypecorresponding to the given method descriptor. Equivalent toType.getType(methodDescriptor).- 参数:
methodDescriptor- a method descriptor.- 返回:
- the
Typecorresponding to the given method descriptor.
-
fromMethod
Returns the methodTypecorresponding to the given argument and return types.- 参数:
returnType- the return type of the method.argumentTypes- the argument types of the method.- 返回:
- 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.- 返回:
- the argument types of methods of this type.
-
getArgumentTypes
Returns theTypevalues corresponding to the argument types of the given method descriptor.- 参数:
methodDescriptor- a method descriptor.- 返回:
- the
Typevalues corresponding to the argument types of the given method descriptor.
-
getArgumentTypes
Returns theTypevalues corresponding to the argument types of the given method.- 参数:
method- a method.- 返回:
- 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.- 返回:
- the return type of methods of this type.
-
forReturnType
Returns theTypecorresponding to the return type of the given method descriptor.- 参数:
methodDescriptor- a method descriptor.- 返回:
- the
Typecorresponding to the return type of the given method descriptor.
-
forReturnType
Returns theTypecorresponding to the return type of the given method.- 参数:
method- a method.- 返回:
- the
Typecorresponding to the return type of the given method.
-
getReturnTypeOffset
Returns the start index of the return type of the given method descriptor.- 参数:
methodDescriptor- a method descriptor.- 返回:
- the start index of the return type of the given method descriptor.
-
getTypeInternal
private static Type getTypeInternal(String descriptorBuffer, int descriptorBegin, int descriptorEnd) Returns theTypecorresponding to the given field or method descriptor.- 参数:
descriptorBuffer- a buffer containing the field or method descriptor.descriptorBegin- the beginning index, inclusive, of the field or method descriptor in descriptorBuffer.descriptorEnd- the end index, exclusive, of the field or method descriptor in descriptorBuffer.- 返回:
- the
Typecorresponding to the given type descriptor.
-
getClassName
Returns the binary name of the class corresponding to this type. This method must not be used on method types.- 返回:
- 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.- 返回:
- 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 '/'.- 参数:
clazz- an object or array class.- 返回:
- the internal name of the given class.
-
getDescriptor
Returns the descriptor corresponding to this type.- 返回:
- the descriptor corresponding to this type.
-
getDescriptor
Returns the descriptor corresponding to the given class.- 参数:
clazz- an object class, a primitive class or an array class.- 返回:
- the descriptor corresponding to the given class.
-
getConstructorDescriptor
Returns the descriptor corresponding to the given constructor.- 参数:
constructor- aConstructorobject.- 返回:
- the descriptor of the given constructor.
-
getMethodDescriptor
Returns the descriptor corresponding to the given argument and return types.- 参数:
returnType- the return type of the method.argumentTypes- the argument types of the method.- 返回:
- the descriptor corresponding to the given argument and return types.
-
getMethodDescriptor
Returns the descriptor corresponding to the given method.- 参数:
method- aMethodobject.- 返回:
- the descriptor of the given method.
-
getDescriptor
Object -> Ljava/lang/Object; Object, Object ,Class -> Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Class;
- 从以下版本开始:
- 4.0
-
getDescriptor
@NonNull public static String getDescriptor(String parameterTypes, int startIdx, int endIdx, boolean defaultPackage) Object -> Ljava/lang/Object; Object, Object ,Class -> Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Class;
-
getDescriptor
Returns the descriptor corresponding to the given type name.- 参数:
type- a Java type name.defaultPackage- true if unqualified class names belong to the default package, or false if they correspond to java.lang classes. For instance "Object" means "Object" if this option is true, or "java.lang.Object" otherwise.- 返回:
- the descriptor corresponding to the given type name.
-
appendDescriptor
Appends the descriptor corresponding to this type to the given string buffer.- 参数:
stringBuilder- the string builder to which the descriptor must be appended.
-
appendDescriptor
Appends the descriptor of the given class to the given string builder.- 参数:
clazz- the class whose descriptor must be computed.stringBuilder- the string builder to which the descriptor must be appended.
-
getComponentType
- 从以下版本开始:
- 4.0
-
emulateClassGetName
- 从以下版本开始:
- 4.0
-
toInternalNames
- 从以下版本开始:
- 4.0
-
getBoxedType
get Boxed Type- 返回:
- Boxed Type
- 从以下版本开始:
- 4.0
-
getUnboxedType
- 从以下版本开始:
- 4.0
-
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.- 返回:
- 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.- 返回:
- 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.- 返回:
- 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.- 参数:
methodDescriptor- a method descriptor.- 返回:
- 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.- 参数:
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.- 返回:
- 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.
-
array
ToTypearray- 参数:
items- array item- 返回:
Typearray
-
getTypes
- 从以下版本开始:
- 4.0
-
getTypes
- 从以下版本开始:
- 4.0
-
getStackSize
- 从以下版本开始:
- 4.0
-
isArray
public boolean isArray()Determines if thisTypeobject represents an array class.- 返回:
trueif this object represents an array class;falseotherwise.- 从以下版本开始:
- 4.0
-
isPrimitive
public boolean isPrimitive()Determines if the specifiedTypeobject represents a primitive type.There are nine predefined
Classobjects to represent the eight primitive types and void. These are created by the Java Virtual Machine, and have the same names as the primitive types that they represent, namelyboolean,byte,char,short,int,long,float, anddouble.These objects may only be accessed via the following public static final variables, and are the only
Classobjects for which this method returnstrue.- 返回:
- true if and only if this class represents a primitive type
- 从以下版本开始:
- 4.0
- 另请参阅:
-
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. -
add
-
add
-
add
-