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, e.g. int[]
  • Field Details Link icon

  • Constructor Details Link icon

    • Type Link icon

      protected Type(byte type, String signature)
  • Method Details Link icon

    • getArgumentTypes Link icon

      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 Link icon

      public static 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 returns
      argTypes - what are the argument types
      Returns:
      method signature for given type(s).
    • getReturnType Link icon

      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 Link icon

      public static String getSignature(Method meth)
    • getType Link icon

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

      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 Link icon

      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 Link icon

      public boolean equals(Object o)
      Overrides:
      equals in class Object
      Returns:
      whether the Types are equal
    • getClassName Link icon

      public String getClassName()
    • getSignature Link icon

      public String getSignature()
      Returns:
      signature for given type.
    • getSize Link icon

      public int getSize()
      Returns:
      stack size of this type (2 for long and double, 0 for void, 1 otherwise)
    • getType Link icon

      public byte getType()
      Returns:
      type as defined in Constants
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      hash code of Type
    • normalizeForStackOrLocal Link icon

      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 Link icon

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      Type string, e.g. 'int[]'