Package io.ebean.enhance.asm
Class Type
java.lang.Object
io.ebean.enhance.asm.Type
public final class Type extends Object
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
Fields Modifier and Type Field Description static intARRAYThe sort of array reference types.static intBOOLEANThe sort of thebooleantype.static TypeBOOLEAN_TYPEThebooleantype.static intBYTEThe sort of thebytetype.static TypeBYTE_TYPEThebytetype.static intCHARThe sort of thechartype.static TypeCHAR_TYPEThechartype.static intDOUBLEThe sort of thedoubletype.static TypeDOUBLE_TYPEThedoubletype.static intFLOATThe sort of thefloattype.static TypeFLOAT_TYPEThefloattype.static intINTThe sort of theinttype.static TypeINT_TYPETheinttype.static intLONGThe sort of thelongtype.static TypeLONG_TYPEThelongtype.static intMETHODThe sort of method types.static intOBJECTThe sort of object reference types.static intSHORTThe sort of theshorttype.static TypeSHORT_TYPETheshorttype.static intVOIDThe sort of thevoidtype.static TypeVOID_TYPEThevoidtype. -
Method Summary
Modifier and Type Method Description booleanequals(Object object)Tests if the given object is equal to this type.intgetArgumentsAndReturnSizes()Returns 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[]getArgumentTypes()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.StringgetClassName()Returns the binary name of the class corresponding to this type.static StringgetConstructorDescriptor(Constructor<?> constructor)Returns the descriptor corresponding to the given constructor.StringgetDescriptor()Returns the descriptor corresponding to this type.static StringgetDescriptor(Class<?> clazz)Returns the descriptor corresponding to the given class.intgetDimensions()Returns the number of dimensions of this array type.TypegetElementType()Returns the type of the elements of this array type.StringgetInternalName()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 TypegetMethodType(Type returnType, Type... argumentTypes)Returns the methodTypecorresponding to the given argument and return types.static TypegetMethodType(String methodDescriptor)Returns theTypecorresponding to the given method descriptor.static TypegetObjectType(String internalName)Returns theTypecorresponding to the given internal name.intgetOpcode(int opcode)Returns a JVM instruction opcode adapted to thisType.TypegetReturnType()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 TypegetType(Class<?> clazz)Returns theTypecorresponding to the given class.static TypegetType(Constructor<?> constructor)Returns the methodTypecorresponding to the given constructor.static TypegetType(Method method)Returns the methodTypecorresponding to the given method.static TypegetType(String typeDescriptor)Returns theTypecorresponding to the given type descriptor.inthashCode()Returns a hash code value for this type.StringtoString()Returns a string representation of this type.
-
Field Details
-
VOID
The sort of thevoidtype. SeegetSort().- See Also:
- Constant Field Values
-
BOOLEAN
The sort of thebooleantype. SeegetSort().- See Also:
- Constant Field Values
-
CHAR
The sort of thechartype. SeegetSort().- See Also:
- Constant Field Values
-
BYTE
The sort of thebytetype. SeegetSort().- See Also:
- Constant Field Values
-
SHORT
The sort of theshorttype. SeegetSort().- See Also:
- Constant Field Values
-
INT
The sort of theinttype. SeegetSort().- See Also:
- Constant Field Values
-
FLOAT
The sort of thefloattype. SeegetSort().- See Also:
- Constant Field Values
-
LONG
The sort of thelongtype. SeegetSort().- See Also:
- Constant Field Values
-
DOUBLE
The sort of thedoubletype. SeegetSort().- See Also:
- Constant Field Values
-
ARRAY
The sort of array reference types. SeegetSort().- See Also:
- Constant Field Values
-
OBJECT
The sort of object reference types. SeegetSort().- See Also:
- Constant Field Values
-
METHOD
The sort of method types. SeegetSort().- See Also:
- Constant Field Values
-
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
Returns the sort of this type. -
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
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
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
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
Returns a hash code value for this type. -
toString
Returns a string representation of this type.
-