Class TypeInfo

java.lang.Object
org.mozilla.classfile.TypeInfo

final class TypeInfo extends Object
Helper class for internal representations of type information. In most cases, type information can be represented by a constant, but in some cases, a payload is included. Despite the payload coming after the type tag in the output, we store it in bits 8-23 for uniformity; the tag is always in bits 0-7.
  • Field Details

  • Constructor Details

    • TypeInfo

      private TypeInfo()
  • Method Details

    • OBJECT

      static final int OBJECT(int constantPoolIndex)
    • OBJECT

      static final int OBJECT(String type, ConstantPool pool)
    • UNINITIALIZED_VARIABLE

      static final int UNINITIALIZED_VARIABLE(int bytecodeOffset)
    • getTag

      static final int getTag(int typeInfo)
    • getPayload

      static final int getPayload(int typeInfo)
    • getPayloadAsType

      static final String getPayloadAsType(int typeInfo, ConstantPool pool)
      Treat the result of getPayload as a constant pool index and fetch the corresponding String mapped to it.

      Only works on OBJECT types.

    • fromType

      static final int fromType(String type, ConstantPool pool)
      Create type information from an internal type.
    • isTwoWords

      static boolean isTwoWords(int type)
    • merge

      static int merge(int current, int incoming, ConstantPool pool)
      Merge two verification types.

      In most cases, the verification types must be the same. For example, INTEGER and DOUBLE cannot be merged and an exception will be thrown. The basic rules are:

      - If the types are equal, simply return one. - If either type is TOP, return TOP. - If either type is NULL, return the other type. - If both types are objects, find the lowest common ancestor in the class hierarchy.

      This method uses reflection to traverse the class hierarchy. Therefore, it is assumed that the current class being generated is never the target of a full object-object merge, which would need to load the current class reflectively.

    • toString

      static String toString(int type, ConstantPool pool)
    • getClassFromInternalName

      private static Class<?> getClassFromInternalName(String internalName)
      Take an internal name and return a java.lang.Class instance that represents it.

      For example, given "java/lang/Object", returns the equivalent of Class.forName("java.lang.Object"), but also handles exceptions.

    • toString

      private static String toString(int[] types, int typesTop, ConstantPool pool)
    • print

      static void print(int[] locals, int[] stack, ConstantPool pool)
    • print

      static void print(int[] locals, int localsTop, int[] stack, int stackTop, ConstantPool pool)