Class Type
- java.lang.Object
-
- org.gjt.sp.jedit.bsh.org.objectweb.asm.Type
-
public class Type extends java.lang.ObjectA Java type. This class can be used to make it easier to manipulate type and method descriptors.
-
-
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 intOBJECTThe sort of object reference type.static intSHORTThe sort of theshorttype.static TypeSHORT_TYPETheshorttype.static intVOIDThe sort of thevoidtype.static TypeVOID_TYPEThevoidtype.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Type[]getArgumentTypes(java.lang.reflect.Method method)Returns the Java types corresponding to the argument types of the given method.static Type[]getArgumentTypes(java.lang.String methodDescriptor)Returns the Java types corresponding to the argument types of the given method descriptor.java.lang.StringgetClassName()Returns the name of the class corresponding to this object type.java.lang.StringgetDescriptor()Returns the descriptor corresponding to this Java type.static java.lang.StringgetDescriptor(java.lang.Class c)Returns the descriptor corresponding to the given Java type.intgetDimensions()Returns the number of dimensions of this array type.TypegetElementType()Returns the type of the elements of this array type.java.lang.StringgetInternalName()Returns the internal name of the class corresponding to this object type.static java.lang.StringgetInternalName(java.lang.Class c)Returns the internal name of the given class.static java.lang.StringgetMethodDescriptor(java.lang.reflect.Method m)Returns the descriptor corresponding to the given method.static java.lang.StringgetMethodDescriptor(Type returnType, Type[] argumentTypes)Returns the descriptor corresponding to the given argument and return types.intgetOpcode(int opcode)Returns a JVM instruction opcode adapted to this Java type.static TypegetReturnType(java.lang.reflect.Method method)Returns the Java type corresponding to the return type of the given method.static TypegetReturnType(java.lang.String methodDescriptor)Returns the Java type corresponding to the return type of the given method descriptor.intgetSize()Returns the size of values of this type.intgetSort()Returns the sort of this Java type.static TypegetType(java.lang.Class c)Returns the Java type corresponding to the given class.static TypegetType(java.lang.String typeDescriptor)Returns the Java type corresponding to the given type descriptor.
-
-
-
Field Detail
-
VOID
public static final int VOID
The sort of thevoidtype. SeegetSort.- See Also:
- Constant Field Values
-
BOOLEAN
public static final int BOOLEAN
The sort of thebooleantype. SeegetSort.- See Also:
- Constant Field Values
-
CHAR
public static final int CHAR
The sort of thechartype. SeegetSort.- See Also:
- Constant Field Values
-
BYTE
public static final int BYTE
The sort of thebytetype. SeegetSort.- See Also:
- Constant Field Values
-
SHORT
public static final int SHORT
The sort of theshorttype. SeegetSort.- See Also:
- Constant Field Values
-
INT
public static final int INT
The sort of theinttype. SeegetSort.- See Also:
- Constant Field Values
-
FLOAT
public static final int FLOAT
The sort of thefloattype. SeegetSort.- See Also:
- Constant Field Values
-
LONG
public static final int LONG
The sort of thelongtype. SeegetSort.- See Also:
- Constant Field Values
-
DOUBLE
public static final int DOUBLE
The sort of thedoubletype. SeegetSort.- See Also:
- Constant Field Values
-
ARRAY
public static final int ARRAY
The sort of array reference types. SeegetSort.- See Also:
- Constant Field Values
-
OBJECT
public static final int OBJECT
The sort of object reference type. SeegetSort.- See Also:
- Constant Field Values
-
VOID_TYPE
public static final Type VOID_TYPE
Thevoidtype.
-
BOOLEAN_TYPE
public static final Type BOOLEAN_TYPE
Thebooleantype.
-
CHAR_TYPE
public static final Type CHAR_TYPE
Thechartype.
-
BYTE_TYPE
public static final Type BYTE_TYPE
Thebytetype.
-
SHORT_TYPE
public static final Type SHORT_TYPE
Theshorttype.
-
INT_TYPE
public static final Type INT_TYPE
Theinttype.
-
FLOAT_TYPE
public static final Type FLOAT_TYPE
Thefloattype.
-
LONG_TYPE
public static final Type LONG_TYPE
Thelongtype.
-
DOUBLE_TYPE
public static final Type DOUBLE_TYPE
Thedoubletype.
-
-
Method Detail
-
getType
public static Type getType(java.lang.String typeDescriptor)
Returns the Java type corresponding to the given type descriptor.- Parameters:
typeDescriptor- a type descriptor.- Returns:
- the Java type corresponding to the given type descriptor.
-
getType
public static Type getType(java.lang.Class c)
Returns the Java type corresponding to the given class.- Parameters:
c- a class.- Returns:
- the Java type corresponding to the given class.
-
getArgumentTypes
public static Type[] getArgumentTypes(java.lang.String methodDescriptor)
Returns the Java types corresponding to the argument types of the given method descriptor.- Parameters:
methodDescriptor- a method descriptor.- Returns:
- the Java types corresponding to the argument types of the given method descriptor.
-
getArgumentTypes
public static Type[] getArgumentTypes(java.lang.reflect.Method method)
Returns the Java types corresponding to the argument types of the given method.- Parameters:
method- a method.- Returns:
- the Java types corresponding to the argument types of the given method.
-
getReturnType
public static Type getReturnType(java.lang.String methodDescriptor)
Returns the Java type corresponding to the return type of the given method descriptor.- Parameters:
methodDescriptor- a method descriptor.- Returns:
- the Java type corresponding to the return type of the given method descriptor.
-
getReturnType
public static Type getReturnType(java.lang.reflect.Method method)
Returns the Java type corresponding to the return type of the given method.- Parameters:
method- a method.- Returns:
- the Java type corresponding to the return type of the given method.
-
getSort
public int getSort()
Returns the sort of this Java 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.
-
getElementType
public Type 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.
-
getClassName
public java.lang.String getClassName()
Returns the name of the class corresponding to this object type. This method should only be used for an object type.- Returns:
- the fully qualified name of the class corresponding to this object type.
-
getInternalName
public java.lang.String getInternalName()
Returns the internal name of the class corresponding to this object type. The internal name of a class is its fully qualified name, where '.' are replaced by '/'. * This method should only be used for an object type.- Returns:
- the internal name of the class corresponding to this object type.
-
getDescriptor
public java.lang.String getDescriptor()
Returns the descriptor corresponding to this Java type.- Returns:
- the descriptor corresponding to this Java type.
-
getMethodDescriptor
public static java.lang.String getMethodDescriptor(Type returnType, Type[] argumentTypes)
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.
-
getInternalName
public static java.lang.String getInternalName(java.lang.Class c)
Returns the internal name of the given class. The internal name of a class is its fully qualified name, where '.' are replaced by '/'.- Parameters:
c- an object class.- Returns:
- the internal name of the given class.
-
getDescriptor
public static java.lang.String getDescriptor(java.lang.Class c)
Returns the descriptor corresponding to the given Java type.- Parameters:
c- an object class, a primitive class or an array class.- Returns:
- the descriptor corresponding to the given class.
-
getMethodDescriptor
public static java.lang.String getMethodDescriptor(java.lang.reflect.Method m)
Returns the descriptor corresponding to the given method.- Parameters:
m- aMethodobject.- Returns:
- the descriptor of the given method.
-
getSize
public int getSize()
Returns the size of values of this type.- Returns:
- the size of values of this type, i.e., 2 for
longanddouble, and 1 otherwise.
-
getOpcode
public int getOpcode(int opcode)
Returns a JVM instruction opcode adapted to this Java type.- 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
Java type. For example, if this type is
floatandopcodeis IRETURN, this method returns FRETURN.
-
-