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 java.lang.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
Empty array.static ReferenceType
NULL
static ObjectType
OBJECT
static BasicType
SHORT
protected java.lang.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
-
Constructor Summary
Constructors Modifier Constructor Description protected
Type(byte type, java.lang.String signature)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static Type[]
getArgumentTypes(java.lang.String signature)
Convert arguments of a method (signature) to an array of Type objects.java.lang.String
getClassName()
static java.lang.String
getMethodSignature(Type returnType, Type[] argTypes)
Convert type to Java method signature, e.g.static Type
getReturnType(java.lang.String signature)
Convert return value of a method (signature) to a Type object.java.lang.String
getSignature()
static java.lang.String
getSignature(java.lang.reflect.Method meth)
int
getSize()
byte
getType()
static Type
getType(java.lang.Class<?> cls)
Convert runtime java.lang.Class to BCEL Type object.static Type
getType(java.lang.String signature)
Convert signature to a Type object.static Type[]
getTypes(java.lang.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.java.lang.String
toString()
-
-
-
Field Detail
-
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
-
NULL
public static final ReferenceType NULL
-
type
@Deprecated protected byte type
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
signature
@Deprecated protected java.lang.String signature
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
-
Constructor Detail
-
Type
protected Type(byte type, java.lang.String signature)
-
-
Method Detail
-
getArgumentTypes
public static Type[] getArgumentTypes(java.lang.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 java.lang.String getMethodSignature(Type returnType, Type[] argTypes)
Convert type to Java method signature, e.g. int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I- Parameters:
returnType
- what the method returnsargTypes
- what are the argument types- Returns:
- method signature for given type(s).
-
getReturnType
public static Type getReturnType(java.lang.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 static java.lang.String getSignature(java.lang.reflect.Method meth)
-
getType
public static Type getType(java.lang.Class<?> cls)
Convert runtime java.lang.Class to BCEL Type object.- Parameters:
cls
- Java class- Returns:
- corresponding Type object
-
getType
public static Type getType(java.lang.String signature) throws java.lang.StringIndexOutOfBoundsException
Convert signature to a Type object.- Parameters:
signature
- signature string such as Ljava/lang/String;- Returns:
- type object
- Throws:
java.lang.StringIndexOutOfBoundsException
-
getTypes
public static Type[] getTypes(java.lang.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
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
- Returns:
- whether the Types are equal
-
getClassName
public java.lang.String getClassName()
-
getSignature
public java.lang.String getSignature()
- Returns:
- signature for given type.
-
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
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hash code of Type
-
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- Type string, e.g. 'int[]'
-
-