# 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, for example int[]

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final BasicType`
  `BOOLEAN`
  `static final BasicType`
  `BYTE`
  `static final BasicType`
  `CHAR`
  `static final ObjectType`
  `CLASS`
  `static final BasicType`
  `DOUBLE`
  `static final BasicType`
  `FLOAT`
  `static final BasicType`
  `INT`
  `static final BasicType`
  `LONG`
  `static final Type[]`
  `NO_ARGS`
  Empty array.
  `static final ReferenceType`
  `NULL`
  `static final ObjectType`
  `OBJECT`
  `static final BasicType`
  `SHORT`
  `protected String`
  `signature`
  Deprecated.
  (since 6.0) will be made private; do not access directly, use getter/setter
  `static final ObjectType`
  `STRING`
  `static final ObjectType`
  `STRINGBUFFER`
  `static final ObjectType`
  `THROWABLE`
  `protected byte`
  `type`
  Deprecated.
  (since 6.0) will be made private; do not access directly, use getter/setter
  `static final Type`
  `UNKNOWN`
  `static final BasicType`
  `VOID`
  Predefined constants

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `Type(byte type, String signature)`

- ## Method Summary

  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.
  `String`
  `getClassName()`
  `static 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
  `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<?> cls)`
  Convert runtime `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()`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### 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
    Empty array.

  - ### NULL

    public static final ReferenceType NULL

  - ### UNKNOWN

    public static final Type UNKNOWN

  - ### 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

- ## Constructor Details

  - ### Type

    protected Type(byte type, String signature)

- ## Method Details

  - ### 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 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(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 String getSignature(Method meth)

  - ### getType

    public static Type getType(Class<?> cls)
    Convert runtime `Class` to BCEL Type object.
    Parameters:
      `cls` - Java class
    Returns:
      corresponding Type object

  - ### 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`

  - ### 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

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`
    Returns:
      whether the Types are equal

  - ### getClassName

    public String getClassName()

  - ### getSignature

    public 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 class `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. Returns `INT` for `BOOLEAN`, `SHORT` or `CHAR`, otherwise returns the given type.
    Since:
      6.0

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`
    Returns:
      Type string, for example 'int[]'