org.objectweb.asm
Class Type

java.lang.Object
  |
  +--org.objectweb.asm.Type

public class Type
extends Object

A Java type. This class can be used to make it easier to manipulate type and method descriptors.


Field Summary
static int ARRAY
          The sort of array reference types.
static int BOOLEAN
          The sort of the boolean type.
static int BYTE
          The sort of the byte type.
static int CHAR
          The sort of the char type.
static int DOUBLE
          The sort of the double type.
static int FLOAT
          The sort of the float type.
static int INT
          The sort of the int type.
static int LONG
          The sort of the long type.
static int OBJECT
          The sort of object reference type.
static int SHORT
          The sort of the short type.
static int VOID
          The sort of the void type.
 
Method Summary
static Type[] getArgumentTypes(String methodDescriptor)
          Returns the Java types corresponding to the argument types of the given method descriptor.
 String getClassName()
          Returns the name of the class corresponding to this object type.
 String getDescriptor()
          Returns the descriptor corresponding to this Java type.
static String getDescriptor(Class c)
          Returns the descriptor corresponding to the given Java type.
 int getDimensions()
          Returns the number of dimensions of this array type.
 Type getElementType()
          Returns the type of the elements of this array type.
static String getInternalName(Class c)
          Returns the internal name of the given class.
static String getMethodDescriptor(Method m)
          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.
 int getOpcode(int opcode)
          Returns a JVM instruction opcode adapted to this Java type.
static Type getReturnType(String methodDescriptor)
          Returns the Java type 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 Java type.
static Type getType(String typeDescriptor)
          Returns the Java type corresponding to the given type descriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VOID

public static final int VOID
The sort of the void type. See getSort.

BOOLEAN

public static final int BOOLEAN
The sort of the boolean type. See getSort.

CHAR

public static final int CHAR
The sort of the char type. See getSort.

BYTE

public static final int BYTE
The sort of the byte type. See getSort.

SHORT

public static final int SHORT
The sort of the short type. See getSort.

INT

public static final int INT
The sort of the int type. See getSort.

FLOAT

public static final int FLOAT
The sort of the float type. See getSort.

LONG

public static final int LONG
The sort of the long type. See getSort.

DOUBLE

public static final int DOUBLE
The sort of the double type. See getSort.

ARRAY

public static final int ARRAY
The sort of array reference types. See getSort.

OBJECT

public static final int OBJECT
The sort of object reference type. See getSort.
Method Detail

getType

public static Type getType(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.

getArgumentTypes

public static Type[] getArgumentTypes(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.

getReturnType

public static Type getReturnType(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.

getSort

public int getSort()
Returns the sort of this Java type.
Returns:
VOID, BOOLEAN, CHAR, BYTE, SHORT, INT, FLOAT, LONG, DOUBLE, ARRAY or OBJECT.

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 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.

getDescriptor

public String getDescriptor()
Returns the descriptor corresponding to this Java type.
Returns:
the descriptor corresponding to this Java type.

getInternalName

public static String getInternalName(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 String getDescriptor(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 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.

getMethodDescriptor

public static String getMethodDescriptor(Method m)
Returns the descriptor corresponding to the given method.
Parameters:
m - a Method object.
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 long and double, 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 float and opcode is IRETURN, this method returns FRETURN.