Package org.apache.bcel.generic
Class Type
- java.lang.Object
-
- org.apache.bcel.generic.Type
-
- Direct Known Subclasses:
BasicType
,DOUBLE_Upper
,LONG_Upper
,ReferenceType
,ReturnaddressType
public abstract class Type extends Object
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
Fields Modifier and Type Field Description static BasicType
BOOLEAN
static BasicType
BYTE
static BasicType
CHAR
static ObjectType
CLASS
static BasicType
DOUBLE
static BasicType
FLOAT
static BasicType
INT
static BasicType
LONG
static Type[]
NO_ARGS
static ReferenceType
NULL
static ObjectType
OBJECT
static BasicType
SHORT
protected String
signature
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setterstatic ObjectType
STRING
static ObjectType
STRINGBUFFER
static ObjectType
THROWABLE
protected byte
type
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setterstatic Type
UNKNOWN
static BasicType
VOID
Predefined constants
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static Type[]
getArgumentTypes(String signature)
Convert arguments of a method (signature) to an array of Type objects.static String
getMethodSignature(Type return_type, Type[] arg_types)
Convert type to Java method signature, e.g.static Type
getReturnType(String signature)
Convert return value of a method (signature) to a Type object.String
getSignature()
static String
getSignature(Method meth)
int
getSize()
byte
getType()
static Type
getType(Class<?> cl)
Convert runtime java.lang.Class to BCEL Type object.static Type
getType(String signature)
Convert signature to a Type object.static Type[]
getTypes(Class<?>[] classes)
Convert runtime java.lang.Class[] to BCEL Type objects.int
hashCode()
Type
normalizeForStackOrLocal()
boolean, short and char variable are considered as int in the stack or local variable area.String
toString()
-
-
-
Field Detail
-
type
@Deprecated protected byte type
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
signature
@Deprecated protected String signature
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
VOID
public static final BasicType VOID
Predefined constants
-
BOOLEAN
public static final BasicType BOOLEAN
-
INT
public static final BasicType INT
-
SHORT
public static final BasicType SHORT
-
BYTE
public static final BasicType BYTE
-
LONG
public static final BasicType LONG
-
DOUBLE
public static final BasicType DOUBLE
-
FLOAT
public static final BasicType FLOAT
-
CHAR
public static final BasicType CHAR
-
OBJECT
public static final ObjectType OBJECT
-
CLASS
public static final ObjectType CLASS
-
STRING
public static final ObjectType STRING
-
STRINGBUFFER
public static final ObjectType STRINGBUFFER
-
THROWABLE
public static final ObjectType THROWABLE
-
NO_ARGS
public static final Type[] NO_ARGS
-
NULL
public static final ReferenceType NULL
-
UNKNOWN
public static final Type UNKNOWN
-
-
Constructor Detail
-
Type
protected Type(byte t, String s)
-
-
Method Detail
-
equals
public boolean equals(Object o)
-
getSignature
public String getSignature()
- Returns:
- signature for given type.
-
getType
public byte getType()
- Returns:
- type as defined in Constants
-
normalizeForStackOrLocal
public Type normalizeForStackOrLocal()
boolean, short and char variable are considered as int in the stack or local variable area. ReturnsINT
forBOOLEAN
,SHORT
orCHAR
, otherwise returns the given type.- Since:
- 6.0
-
getSize
public int getSize()
- Returns:
- stack size of this type (2 for long and double, 0 for void, 1 otherwise)
-
toString
public String toString()
-
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 returnsarg_types
- what are the argument types- Returns:
- method signature for given type(s).
-
getType
public static Type getType(String signature) throws StringIndexOutOfBoundsException
Convert signature to a Type object.- Parameters:
signature
- signature string such as Ljava/lang/String;- Returns:
- type object
- Throws:
StringIndexOutOfBoundsException
-
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
-
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
-
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
-
-