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
Abstract superclass for all possible Java types, namely basic types such as int, object types like String and array
types, for example int[]
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BasicTypePredefined constant for boolean type.static final BasicTypePredefined constant for byte type.static final BasicTypePredefined constant for char type.static final ObjectTypePredefined constant for Class type.private static final ThreadLocal<Integer>static final BasicTypePredefined constant for double type.static final BasicTypePredefined constant for float type.static final BasicTypePredefined constant for int type.static final BasicTypePredefined constant for long type.static final Type[]Empty array.static final ReferenceTypePredefined constant for null type.static final ObjectTypePredefined constant for Object type.static final BasicTypePredefined constant for short type.protected StringDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterstatic final ObjectTypePredefined constant for String type.static final ObjectTypePredefined constant for StringBuffer type.static final ObjectTypePredefined constant for Throwable type.protected byteDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterstatic final TypePredefined constant for unknown type.static final BasicTypePredefined constants -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static intconsumed(int coded) (package private) static intencode(int size, int consumed) booleanstatic Type[]getArgumentTypes(String signature) Gets the argument types of a method from its signature as an array of Type objects.(package private) static intgetArgumentTypesSize(String signature) Gets the class name.static StringgetMethodSignature(Type returnType, Type[] argTypes) Gets the Java method signature for the given types, for example, int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I.static TypegetReturnType(String signature) Gets the return type of a method from its signature as a Type object.(package private) static intgetReturnTypeSize(String signature) Gets the signature for this type.static StringgetSignature(Method meth) Gets the signature for a method.intgetSize()Gets the stack size of this type.bytegetType()Gets the type as defined in Constants.static TypeGets the BCEL Type object corresponding to a runtimeClass.static TypeGets the Type object corresponding to a signature.static Type[]Gets the BCEL Type objects corresponding to an array of runtime classes.(package private) static intgetTypeSize(String signature) inthashCode()Gets the hash code of this Type.(package private) static StringinternalTypeNameToSignature(String internalTypeName) boolean, short and char variable are considered as int in the stack or local variable area.(package private) static intsize(int coded) toString()private static intunwrap(ThreadLocal<Integer> tl) private static voidwrap(ThreadLocal<Integer> tl, int value)
-
Field Details
-
VOID
Predefined constants -
BOOLEAN
Predefined constant for boolean type. -
INT
Predefined constant for int type. -
SHORT
Predefined constant for short type. -
BYTE
Predefined constant for byte type. -
LONG
Predefined constant for long type. -
DOUBLE
Predefined constant for double type. -
FLOAT
Predefined constant for float type. -
CHAR
Predefined constant for char type. -
OBJECT
Predefined constant for Object type. -
CLASS
Predefined constant for Class type. -
STRING
Predefined constant for String type. -
STRINGBUFFER
Predefined constant for StringBuffer type. -
THROWABLE
Predefined constant for Throwable type. -
NO_ARGS
Empty array. -
NULL
Predefined constant for null type. -
UNKNOWN
Predefined constant for unknown type. -
CONSUMED_CHARS
-
type
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter -
signature
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
-
Constructor Details
-
Type
Constructs a Type.- Parameters:
type- The type constant.signature- The type signature.
-
-
Method Details
-
consumed
static int consumed(int coded) -
encode
static int encode(int size, int consumed) -
getArgumentTypes
Gets the argument types of a method from its signature as an array of Type objects.- Parameters:
signature- signature string such as (Ljava/lang/String;)V.- Returns:
- array of argument types.
-
getArgumentTypesSize
-
getMethodSignature
Gets the Java method signature for the given types, for example, int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I.- Parameters:
returnType- what the method returns.argTypes- what are the argument types.- Returns:
- method signature for given type(s).
-
getReturnType
Gets the return type of a method from its signature as a Type object.- Parameters:
signature- signature string such as (Ljava/lang/String;)V.- Returns:
- return type.
-
getReturnTypeSize
-
getSignature
Gets the signature for a method.- Parameters:
meth- The method.- Returns:
- The method signature.
-
getType
Gets the BCEL Type object corresponding to a runtimeClass.- Parameters:
cls- Java class.- Returns:
- corresponding Type object.
-
getType
Gets the Type object corresponding to a signature.- Parameters:
signature- signature string such as Ljava/lang/String;.- Returns:
- type object.
- Throws:
StringIndexOutOfBoundsException
-
getTypes
Gets the BCEL Type objects corresponding to an array of runtime classes.- Parameters:
classes- An array of runtime class objects.- Returns:
- array of corresponding Type objects.
-
getTypeSize
- Throws:
StringIndexOutOfBoundsException
-
internalTypeNameToSignature
-
size
static int size(int coded) -
unwrap
-
wrap
-
equals
-
getClassName
Gets the class name.- Returns:
- The class name.
-
getSignature
Gets the signature for this type.- Returns:
- signature for given type.
-
getSize
public int getSize()Gets the stack size of this type.- Returns:
- stack size of this type (2 for long and double, 0 for void, 1 otherwise).
-
getType
public byte getType()Gets the type as defined in Constants.- Returns:
- type as defined in Constants.
-
hashCode
public int hashCode()Gets the hash code of this Type. -
normalizeForStackOrLocal
boolean, short and char variable are considered as int in the stack or local variable area. ReturnsINTforBOOLEAN,SHORTorCHAR, otherwise returns the given type.- Returns:
- The normalized type.
- Since:
- 6.0
-
toString
-