public class

Type

extends Object
java.lang.Object
   ↳ org.eclipse.sisu.space.asm.Type

Class Overview

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

Summary

Constants
int ARRAY The sort of array reference types.
int BOOLEAN The sort of the boolean type.
int BYTE The sort of the byte type.
int CHAR The sort of the char type.
int DOUBLE The sort of the double type.
int FLOAT The sort of the float type.
int INT The sort of the int type.
int LONG The sort of the long type.
int METHOD The sort of method types.
int OBJECT The sort of object reference types.
int SHORT The sort of the short type.
int VOID The sort of the void type.
Fields
public static final Type BOOLEAN_TYPE The boolean type.
public static final Type BYTE_TYPE The byte type.
public static final Type CHAR_TYPE The char type.
public static final Type DOUBLE_TYPE The double type.
public static final Type FLOAT_TYPE The float type.
public static final Type INT_TYPE The int type.
public static final Type LONG_TYPE The long type.
public static final Type SHORT_TYPE The short type.
public static final Type VOID_TYPE The void type.
Public Methods
boolean equals(Object o)
Tests if the given object is equal to this type.
Type[] getArgumentTypes()
Returns the argument types of methods of this type.
static Type[] getArgumentTypes(Method method)
Returns the Java types corresponding to the argument types of the given method.
static Type[] getArgumentTypes(String methodDescriptor)
Returns the Java types corresponding to the argument types of the given method descriptor.
static int getArgumentsAndReturnSizes(String desc)
Computes the size of the arguments and of the return value of a method.
int getArgumentsAndReturnSizes()
Returns the size of the arguments and of the return value of methods of this type.
String getClassName()
Returns the binary name of the class corresponding to this type.
static String getConstructorDescriptor(Constructor<?> c)
Returns the descriptor corresponding to the given constructor.
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.
String getInternalName()
Returns the internal name of the class corresponding to this object or array type.
static String getInternalName(Class<?> c)
Returns the internal name of the given class.
static String getMethodDescriptor(Type returnType, Type... argumentTypes)
Returns the descriptor corresponding to the given argument and return types.
static String getMethodDescriptor(Method m)
Returns the descriptor corresponding to the given method.
static Type getMethodType(Type returnType, Type... argumentTypes)
Returns the Java method type corresponding to the given argument and return types.
static Type getMethodType(String methodDescriptor)
Returns the Java type corresponding to the given method descriptor.
static Type getObjectType(String internalName)
Returns the Java type corresponding to the given internal name.
int getOpcode(int opcode)
Returns a JVM instruction opcode adapted to this Java type.
Type getReturnType()
Returns the return type of methods of this type.
static Type getReturnType(Method method)
Returns the Java type corresponding to the return type of the given method.
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(Constructor<?> c)
Returns the Java method type corresponding to the given constructor.
static Type getType(Class<?> c)
Returns the Java type corresponding to the given class.
static Type getType(String typeDescriptor)
Returns the Java type corresponding to the given type descriptor.
static Type getType(Method m)
Returns the Java method type corresponding to the given method.
int hashCode()
Returns a hash code value for this type.
String toString()
Returns a string representation of this type.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ARRAY

The sort of array reference types. See getSort.

Constant Value: 9 (0x00000009)

public static final int BOOLEAN

The sort of the boolean type. See getSort.

Constant Value: 1 (0x00000001)

public static final int BYTE

The sort of the byte type. See getSort.

Constant Value: 3 (0x00000003)

public static final int CHAR

The sort of the char type. See getSort.

Constant Value: 2 (0x00000002)

public static final int DOUBLE

The sort of the double type. See getSort.

Constant Value: 8 (0x00000008)

public static final int FLOAT

The sort of the float type. See getSort.

Constant Value: 6 (0x00000006)

public static final int INT

The sort of the int type. See getSort.

Constant Value: 5 (0x00000005)

public static final int LONG

The sort of the long type. See getSort.

Constant Value: 7 (0x00000007)

public static final int METHOD

The sort of method types. See getSort.

Constant Value: 11 (0x0000000b)

public static final int OBJECT

The sort of object reference types. See getSort.

Constant Value: 10 (0x0000000a)

public static final int SHORT

The sort of the short type. See getSort.

Constant Value: 4 (0x00000004)

public static final int VOID

The sort of the void type. See getSort.

Constant Value: 0 (0x00000000)

Fields

public static final Type BOOLEAN_TYPE

The boolean type.

public static final Type BYTE_TYPE

The byte type.

public static final Type CHAR_TYPE

The char type.

public static final Type DOUBLE_TYPE

The double type.

public static final Type FLOAT_TYPE

The float type.

public static final Type INT_TYPE

The int type.

public static final Type LONG_TYPE

The long type.

public static final Type SHORT_TYPE

The short type.

public static final Type VOID_TYPE

The void type.

Public Methods

public boolean equals (Object o)

Tests if the given object is equal to this type.

Parameters
o the object to be compared to this type.
Returns
  • true if the given object is equal to this type.

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

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

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.

public static int getArgumentsAndReturnSizes (String desc)

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

Parameters
desc the descriptor of a method.
Returns
  • the size of the arguments of the method (plus one for the implicit this argument), argSize, and the size of its return value, retSize, packed into a single int i = (argSize << 2) | retSize (argSize is therefore equal to i >> 2, and retSize to i & 0x03).

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
  • the size of the arguments (plus one for the implicit this argument), argSize, and the size of the return value, retSize, packed into a single int i = (argSize << 2) | retSize (argSize is therefore equal to i >> 2, and retSize to i & 0x03).

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

public static String getConstructorDescriptor (Constructor<?> c)

Returns the descriptor corresponding to the given constructor.

Parameters
c a Constructor Constructor object.
Returns
  • the descriptor of the given constructor.

public String getDescriptor ()

Returns the descriptor corresponding to this Java type.

Returns
  • the descriptor corresponding to this Java type.

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.

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.

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.

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
  • the internal name of the class corresponding to this object type.

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, as returned by Class.getName(), where '.' are replaced by '/'.

Parameters
c an object or array class.
Returns
  • the internal name of the given class.

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.

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.

public static Type getMethodType (Type returnType, Type... argumentTypes)

Returns the Java method type 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 Java type corresponding to the given argument and return types.

public static Type getMethodType (String methodDescriptor)

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

Parameters
methodDescriptor a method descriptor.
Returns
  • the Java type corresponding to the given method descriptor.

public static Type getObjectType (String internalName)

Returns the Java type corresponding to the given internal name.

Parameters
internalName an internal name.
Returns
  • the Java type corresponding to the given internal name.

public int getOpcode (int opcode)

Returns a JVM instruction opcode adapted to this Java type. 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 Java type. For example, if this type is float and opcode is IRETURN, this method returns FRETURN.

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

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

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.

public int 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 long and double, 0 for void and 1 otherwise.

public int getSort ()

Returns the sort of this Java type.

public static Type getType (Constructor<?> c)

Returns the Java method type corresponding to the given constructor.

Parameters
c a Constructor object.
Returns
  • the Java method type corresponding to the given constructor.

public static Type getType (Class<?> c)

Returns the Java type corresponding to the given class.

Parameters
c a class.
Returns
  • the Java type corresponding to the given class.

public static Type getType (String typeDescriptor)

Returns the Java type corresponding to the given type descriptor.

Parameters
typeDescriptor a field or method type descriptor.
Returns
  • the Java type corresponding to the given type descriptor.

public static Type getType (Method m)

Returns the Java method type corresponding to the given method.

Parameters
m a Method object.
Returns
  • the Java method type corresponding to the given method.

public int hashCode ()

Returns a hash code value for this type.

Returns
  • a hash code value for this type.

public String toString ()

Returns a string representation of this type.

Returns
  • the descriptor of this type.