Class Type

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Type​(byte type, java.lang.String signature)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static int consumed​(int coded)  
      (package private) static int encode​(int size, int consumed)  
      boolean equals​(java.lang.Object o)  
      static Type[] getArgumentTypes​(java.lang.String signature)
      Convert arguments of a method (signature) to an array of Type objects.
      (package private) static int getArgumentTypesSize​(java.lang.String signature)  
      java.lang.String getClassName()
      Gets the class name.
      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
      static Type getReturnType​(java.lang.String signature)
      Convert return value of a method (signature) to a Type object.
      (package private) static int getReturnTypeSize​(java.lang.String signature)  
      java.lang.String getSignature()
      Gets the signature for this type.
      static java.lang.String getSignature​(java.lang.reflect.Method meth)  
      int getSize()
      Gets the stack size of this type.
      byte getType()
      Gets the type as defined in Constants.
      static Type getType​(java.lang.Class<?> cls)
      Convert runtime Class to BCEL Type object.
      static Type getType​(java.lang.String signature)
      Convert signature to a Type object.
      static Type[] getTypes​(java.lang.Class<?>[] classes)
      Convert runtime java.lang.Class[] to BCEL Type objects.
      (package private) static int getTypeSize​(java.lang.String signature)  
      int hashCode()
      Gets the hash code of this Type.
      (package private) static java.lang.String internalTypeNameToSignature​(java.lang.String internalTypeName)  
      Type normalizeForStackOrLocal()
      boolean, short and char variable are considered as int in the stack or local variable area.
      (package private) static int size​(int coded)  
      java.lang.String toString()  
      private static int unwrap​(java.lang.ThreadLocal<java.lang.Integer> tl)  
      private static void wrap​(java.lang.ThreadLocal<java.lang.Integer> tl, int value)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • VOID

        public static final BasicType VOID
        Predefined constants
      • BOOLEAN

        public static final BasicType BOOLEAN
      • DOUBLE

        public static final BasicType DOUBLE
      • STRINGBUFFER

        public static final ObjectType STRINGBUFFER
      • THROWABLE

        public static final ObjectType THROWABLE
      • NO_ARGS

        public static final Type[] NO_ARGS
        Empty array.
      • UNKNOWN

        public static final Type UNKNOWN
      • CONSUMED_CHARS

        private static final java.lang.ThreadLocal<java.lang.Integer> CONSUMED_CHARS
      • 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)
    • Method Detail

      • consumed

        static int consumed​(int coded)
      • encode

        static int encode​(int size,
                          int consumed)
      • 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.
      • getArgumentTypesSize

        static int getArgumentTypesSize​(java.lang.String signature)
      • 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.
      • getReturnTypeSize

        static int getReturnTypeSize​(java.lang.String signature)
      • getSignature

        public static java.lang.String getSignature​(java.lang.reflect.Method meth)
      • getType

        public static Type getType​(java.lang.Class<?> cls)
        Convert runtime Class to 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 runtime java.lang.Class[] to BCEL Type objects.
        Parameters:
        classes - an array of runtime class objects.
        Returns:
        array of corresponding Type objects.
      • getTypeSize

        static int getTypeSize​(java.lang.String signature)
                        throws java.lang.StringIndexOutOfBoundsException
        Throws:
        java.lang.StringIndexOutOfBoundsException
      • internalTypeNameToSignature

        static java.lang.String internalTypeNameToSignature​(java.lang.String internalTypeName)
      • size

        static int size​(int coded)
      • unwrap

        private static int unwrap​(java.lang.ThreadLocal<java.lang.Integer> tl)
      • wrap

        private static void wrap​(java.lang.ThreadLocal<java.lang.Integer> tl,
                                 int value)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.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:
        hashCode in class java.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. Returns INT for BOOLEAN, SHORT or CHAR, otherwise returns the given type.
        Returns:
        the normalized type.
        Since:
        6.0
      • toString

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