org.apache.bcel.generic

Class Type

Implemented Interfaces:
java.io.Serializable
Known Direct Subclasses:
BasicType, DOUBLE_Upper, LONG_Upper, ReferenceType, ReturnaddressType

public abstract class Type
extends java.lang.Object
implements java.io.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[]
Version:
$Id: Type.java 393344 2006-04-12 00:38:34Z tcurdt $
Author:
M. Dahm
See Also:
Serialized Form

Field Summary

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
static ObjectType
STRING
static ObjectType
STRINGBUFFER
static ObjectType
THROWABLE
static Type
UNKNOWN
static BasicType
VOID
Predefined constants
private static ThreadLocal
consumed_chars
protected String
signature
protected byte
type

Constructor Summary

Type(byte t, String s)

Method Summary

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(java.lang.reflect.Method meth)
int
getSize()
byte
getType()
static Type
getType(String signature)
Convert signature to a Type object.
static Type
getType(java.lang.Class cl)
Convert runtime java.lang.Class to BCEL Type object.
static Type[]
getTypes(java.lang.Class[] classes)
Convert runtime java.lang.Class[] to BCEL Type objects.
int
hashCode()
String
toString()
private static int
unwrap(ThreadLocal tl)
private static void
wrap(ThreadLocal tl, int value)

Field Details

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

SHORT

public static final BasicType SHORT

STRING

public static final ObjectType STRING

STRINGBUFFER

public static final ObjectType STRINGBUFFER

THROWABLE

public static final ObjectType THROWABLE

UNKNOWN

public static final Type UNKNOWN

VOID

public static final BasicType VOID
Predefined constants

consumed_chars

private static ThreadLocal consumed_chars

signature

protected String signature

type

protected byte type

Constructor Details

Type

protected Type(byte t,
               String s)

Method Details

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(java.lang.reflect.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)
            throws StringIndexOutOfBoundsException
Convert signature to a Type object.
Parameters:
signature - signature string such as Ljava/lang/String;
Returns:
type object

getType

public static Type getType(java.lang.Class cl)
Convert runtime java.lang.Class to BCEL Type object.
Parameters:
cl - Java class
Returns:
corresponding Type object

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

hashCode

public int hashCode()
Returns:
hashcode of Type

toString

public String toString()
Returns:
Type string, e.g. `int[]'

unwrap

private static int unwrap(ThreadLocal tl)

wrap

private static void wrap(ThreadLocal tl,
                         int value)