public class Type
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ARRAY
The sort of array reference types.
|
static int |
BOOLEAN
The sort of the boolean type.
|
static Type |
BOOLEAN_TYPE
The boolean type.
|
private char[] |
buf
A buffer containing the descriptor of this Java type.
|
static int |
BYTE
The sort of the byte type.
|
static Type |
BYTE_TYPE
The byte type.
|
static int |
CHAR
The sort of the char type.
|
static Type |
CHAR_TYPE
The char type.
|
static int |
DOUBLE
The sort of the double type.
|
static Type |
DOUBLE_TYPE
The double type.
|
static int |
FLOAT
The sort of the float type.
|
static Type |
FLOAT_TYPE
The float type.
|
static int |
INT
The sort of the int type.
|
static Type |
INT_TYPE
The int type.
|
private int |
len
The length of the descriptor of this Java type.
|
static int |
LONG
The sort of the long type.
|
static Type |
LONG_TYPE
The long type.
|
static int |
OBJECT
The sort of object reference type.
|
private int |
off
The offset of the descriptor of this Java type in
buf . |
static int |
SHORT
The sort of the short type.
|
static Type |
SHORT_TYPE
The short type.
|
private int |
sort
The sort of this Java type.
|
static int |
VOID
The sort of the void type.
|
static Type |
VOID_TYPE
The void type.
|
Modifier | Constructor and Description |
---|---|
private |
Type(int sort)
Constructs a primitive type.
|
private |
Type(int sort,
char[] buf,
int off,
int len)
Constructs a reference type.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o)
Tests if the given object is equal to this type.
|
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.String |
getClassName()
Returns the name of the class corresponding to this type.
|
static java.lang.String |
getConstructorDescriptor(java.lang.reflect.Constructor c)
Returns the descriptor corresponding to the given constructor.
|
java.lang.String |
getDescriptor()
Returns the descriptor corresponding to this Java type.
|
static java.lang.String |
getDescriptor(java.lang.Class c)
Returns the descriptor corresponding to the given Java type.
|
private void |
getDescriptor(java.lang.StringBuffer buf)
Appends the descriptor corresponding to this Java type to the given
string buffer.
|
private static void |
getDescriptor(java.lang.StringBuffer buf,
java.lang.Class c)
Appends the descriptor of the given class to the given string buffer.
|
int |
getDimensions()
Returns the number of dimensions of this array type.
|
Type |
getElementType()
Returns the type of the elements of this array type.
|
java.lang.String |
getInternalName()
Returns the internal name of the class corresponding to this object type.
|
static java.lang.String |
getInternalName(java.lang.Class c)
Returns the internal name of the given class.
|
static java.lang.String |
getMethodDescriptor(java.lang.reflect.Method m)
Returns the descriptor corresponding to the given method.
|
static java.lang.String |
getMethodDescriptor(Type returnType,
Type[] argumentTypes)
Returns the descriptor corresponding to the given argument and return
types.
|
static Type |
getObjectType(java.lang.String name)
Returns the
OBJECT type for the given internal class name. |
int |
getOpcode(int opcode)
Returns a JVM instruction opcode adapted to this Java type.
|
static Type |
getReturnType(java.lang.reflect.Method method)
Returns the Java type corresponding to the return type of the given
method.
|
static Type |
getReturnType(java.lang.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.
|
private static Type |
getType(char[] buf,
int off)
Returns the Java type corresponding to the given type descriptor.
|
static Type |
getType(java.lang.Class c)
Returns the Java type corresponding to the given class.
|
static Type |
getType(java.lang.String typeDescriptor)
Returns the Java type corresponding to the given type descriptor.
|
int |
hashCode()
Returns a hash code value for this type.
|
java.lang.String |
toString()
Returns a string representation of this type.
|
public static final int VOID
getSort
.public static final int BOOLEAN
getSort
.public static final int CHAR
getSort
.public static final int BYTE
getSort
.public static final int SHORT
getSort
.public static final int INT
getSort
.public static final int FLOAT
getSort
.public static final int LONG
getSort
.public static final int DOUBLE
getSort
.public static final int ARRAY
getSort
.public static final int OBJECT
getSort
.public static final Type VOID_TYPE
public static final Type BOOLEAN_TYPE
public static final Type CHAR_TYPE
public static final Type BYTE_TYPE
public static final Type SHORT_TYPE
public static final Type INT_TYPE
public static final Type FLOAT_TYPE
public static final Type LONG_TYPE
public static final Type DOUBLE_TYPE
private final int sort
private char[] buf
private int off
buf
. This
field is only used for reference types.private int len
private Type(int sort)
sort
- the sort of the primitive type to be constructed.private Type(int sort, char[] buf, int off, int len)
sort
- the sort of the reference type to be constructed.buf
- a buffer containing the descriptor of the previous type.off
- the offset of this descriptor in the previous buffer.len
- the length of this descriptor.public static Type getType(java.lang.String typeDescriptor)
typeDescriptor
- a type descriptor.public static Type getType(java.lang.Class c)
c
- a class.public static Type getObjectType(java.lang.String name)
OBJECT
type for the given internal class name.
This is a shortcut method for Type.getType("L"+name+";")
.
Note that opposed to getType(String)
, this method takes
internal class names and not class descriptor.name
- an internal class name.OBJECT
type for the given class name.public static Type[] getArgumentTypes(java.lang.String methodDescriptor)
methodDescriptor
- a method descriptor.public static Type[] getArgumentTypes(java.lang.reflect.Method method)
method
- a method.public static Type getReturnType(java.lang.String methodDescriptor)
methodDescriptor
- a method descriptor.public static Type getReturnType(java.lang.reflect.Method method)
method
- a method.private static Type getType(char[] buf, int off)
buf
- a buffer containing a type descriptor.off
- the offset of this descriptor in the previous buffer.public int getSort()
public int getDimensions()
public Type getElementType()
public java.lang.String getClassName()
public java.lang.String getInternalName()
public java.lang.String getDescriptor()
public static java.lang.String getMethodDescriptor(Type returnType, Type[] argumentTypes)
returnType
- the return type of the method.argumentTypes
- the argument types of the method.private void getDescriptor(java.lang.StringBuffer buf)
buf
- the string buffer to which the descriptor must be appended.public static java.lang.String getInternalName(java.lang.Class c)
c
- an object class.public static java.lang.String getDescriptor(java.lang.Class c)
c
- an object class, a primitive class or an array class.public static java.lang.String getConstructorDescriptor(java.lang.reflect.Constructor c)
c
- a Constructor
object.public static java.lang.String getMethodDescriptor(java.lang.reflect.Method m)
m
- a Method
object.private static void getDescriptor(java.lang.StringBuffer buf, java.lang.Class c)
buf
- the string buffer to which the descriptor must be appended.c
- the class whose descriptor must be computed.public int getSize()
public int getOpcode(int opcode)
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.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the object to be compared to this type.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object