org.apache.bcel.generic

Class Type

public abstract class Type extends Object implements Serializable

Abstract super class for all possible java types, namely basic types such as int, object types like String and array types, e.g. int[]
Field Summary
static BasicTypeBOOLEAN
static BasicTypeBYTE
static BasicTypeCHAR
static ObjectTypeCLASS
static BasicTypeDOUBLE
static BasicTypeFLOAT
static BasicTypeINT
static BasicTypeLONG
static Type[]NO_ARGS
static ReferenceTypeNULL
static ObjectTypeOBJECT
protected Stringsignature
static BasicTypeSHORT
static ObjectTypeSTRING
static ObjectTypeSTRINGBUFFER
protected bytetype
static ObjectTypeTHROWABLE
static TypeUNKNOWN
static BasicTypeVOID
Predefined constants
Constructor Summary
protected Type(byte t, String s)
Method Summary
booleanequals(Object o)
static Type[]getArgumentTypes(String signature)
Convert arguments of a method (signature) to an array of Type objects.
static StringgetMethodSignature(Type return_type, Type[] arg_types)
Convert type to Java method signature, e.g. int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I
static TypegetReturnType(String signature)
Convert return value of a method (signature) to a Type object.
StringgetSignature()
static StringgetSignature(Method meth)
intgetSize()
bytegetType()
static TypegetType(String signature)
Convert signature to a Type object.
static TypegetType(Class cl)
Convert runtime java.lang.Class to BCEL Type object.
static Type[]getTypes(Class[] classes)
Convert runtime java.lang.Class[] to BCEL Type objects.
inthashCode()
StringtoString()

Field Detail

BOOLEAN

public static final BasicType BOOLEAN

BYTE

public static final BasicType BYTE

CHAR

public static final BasicType CHAR

CLASS

public static final ObjectType CLASS

DOUBLE

public static final BasicType DOUBLE

FLOAT

public static final BasicType FLOAT

INT

public static final BasicType INT

LONG

public static final BasicType LONG

NO_ARGS

public static final Type[] NO_ARGS

NULL

public static final ReferenceType NULL

OBJECT

public static final ObjectType OBJECT

signature

protected String signature

SHORT

public static final BasicType SHORT

STRING

public static final ObjectType STRING

STRINGBUFFER

public static final ObjectType STRINGBUFFER

type

protected final byte type

THROWABLE

public static final ObjectType THROWABLE

UNKNOWN

public static final Type UNKNOWN

VOID

public static final BasicType VOID
Predefined constants

Constructor Detail

Type

protected Type(byte t, String s)

Method Detail

equals

public boolean equals(Object o)

Returns: whether the Types are equal

getArgumentTypes

public static Type[] getArgumentTypes(String signature)
Convert arguments of a method (signature) to an array of Type objects.

Parameters: signature signature string such as (Ljava/lang/String;)V

Returns: array of argument types

getMethodSignature

public static String getMethodSignature(Type return_type, Type[] arg_types)
Convert type to Java method signature, e.g. int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I

Parameters: return_type what the method returns arg_types what are the argument types

Returns: method signature for given type(s).

getReturnType

public static Type getReturnType(String signature)
Convert return value of a method (signature) to a Type object.

Parameters: signature signature string such as (Ljava/lang/String;)V

Returns: return type

getSignature

public String getSignature()

Returns: signature for given type.

getSignature

public static String getSignature(Method meth)

getSize

public int getSize()

Returns: stack size of this type (2 for long and double, 0 for void, 1 otherwise)

getType

public byte getType()

Returns: type as defined in Constants

getType

public static final Type getType(String signature)
Convert signature to a Type object.

Parameters: signature signature string such as Ljava/lang/String;

Returns: type object

getType

public static Type getType(Class cl)
Convert runtime java.lang.Class to BCEL Type object.

Parameters: cl Java class

Returns: corresponding Type object

getTypes

public static Type[] getTypes(Class[] classes)
Convert runtime java.lang.Class[] to BCEL Type objects.

Parameters: classes an array of runtime class objects

Returns: array of corresponding Type objects

hashCode

public int hashCode()

Returns: hashcode of Type

toString

public String toString()

Returns: Type string, e.g. `int[]'