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, for example int[]
-
-
Field Summary
Fields Modifier and Type Field Description static BasicTypeBOOLEANPredefined constant for boolean type.static BasicTypeBYTEPredefined constant for byte type.static BasicTypeCHARPredefined constant for char type.static ObjectTypeCLASSPredefined constant for Class type.static BasicTypeDOUBLEPredefined constant for double type.static BasicTypeFLOATPredefined constant for float type.static BasicTypeINTPredefined constant for int type.static BasicTypeLONGPredefined constant for long type.static Type[]NO_ARGSEmpty array.static ReferenceTypeNULLPredefined constant for null type.static ObjectTypeOBJECTPredefined constant for Object type.static BasicTypeSHORTPredefined constant for short type.protected java.lang.StringsignatureDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterstatic ObjectTypeSTRINGPredefined constant for String type.static ObjectTypeSTRINGBUFFERPredefined constant for StringBuffer type.static ObjectTypeTHROWABLEPredefined constant for Throwable type.protected bytetypeDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterstatic TypeUNKNOWNPredefined constant for unknown type.static BasicTypeVOIDPredefined constants
-
Constructor Summary
Constructors Modifier Constructor Description protectedType(byte type, java.lang.String signature)Constructs a Type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(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.StringgetClassName()Gets the class name.static java.lang.StringgetMethodSignature(Type returnType, Type[] argTypes)Convert type to Java method signature, for example int[] f(java.lang.String x) becomes (Ljava/lang/String;)[Istatic TypegetReturnType(java.lang.String signature)Convert return value of a method (signature) to a Type object.java.lang.StringgetSignature()Gets the signature for this type.static java.lang.StringgetSignature(java.lang.reflect.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 TypegetType(java.lang.Class<?> cls)Convert runtimeClassto BCEL Type object.static TypegetType(java.lang.String signature)Convert signature to a Type object.static Type[]getTypes(java.lang.Class<?>[] classes)Convert runtimejava.lang.Class[]to BCEL Type objects.inthashCode()Gets the hash code of this Type.TypenormalizeForStackOrLocal()boolean, short and char variable are considered as int in the stack or local variable area.java.lang.StringtoString()
-
-
-
Field Detail
-
OBJECT
public static final ObjectType OBJECT
Predefined constant for Object type.
-
CLASS
public static final ObjectType CLASS
Predefined constant for Class type.
-
STRING
public static final ObjectType STRING
Predefined constant for String type.
-
STRINGBUFFER
public static final ObjectType STRINGBUFFER
Predefined constant for StringBuffer type.
-
THROWABLE
public static final ObjectType THROWABLE
Predefined constant for Throwable type.
-
NULL
public static final ReferenceType NULL
Predefined constant for null type.
-
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)
Constructs a Type.- Parameters:
type- The type constant.signature- The type 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, 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
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)
Gets the signature for a method.- Parameters:
meth- The method.- Returns:
- The method signature.
-
getType
public static Type getType(java.lang.Class<?> cls)
Convert runtimeClassto 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 runtimejava.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:
equalsin classjava.lang.Object- Returns:
- whether the Types are equal.
-
getClassName
public java.lang.String getClassName()
Gets the class name.- Returns:
- The class name.
-
getSignature
public java.lang.String 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.- Overrides:
hashCodein 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. ReturnsINTforBOOLEAN,SHORTorCHAR, otherwise returns the given type.- Returns:
- The normalized type.
- Since:
- 6.0
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- Type string, for example 'int[]'.
-
-