Class JavaType

java.lang.Object
mockit.asm.types.JavaType
Direct Known Subclasses:
PrimitiveType, ReferenceType

public abstract class JavaType extends Object
A Java field or method type. This class can be used to make it easier to manipulate type and method descriptors.
  • Method Details

    • getType

      @NonNull public static JavaType getType(@NonNull String typeDescriptor)
      Returns the Java type corresponding to the given type descriptor.
      Parameters:
      typeDescriptor - a field or method type descriptor.
    • getArgumentTypes

      @NonNull public static JavaType[] getArgumentTypes(@NonNull String methodDescriptor)
      Returns the Java types corresponding to the argument types of the given method descriptor.
    • getReturnType

      @NonNull public static JavaType getReturnType(@NonNull String methodDescriptor)
      Returns the Java type corresponding to the return type of the given method descriptor.
    • getArgumentsAndReturnSizes

      public static int getArgumentsAndReturnSizes(@NonNull String desc)
      Computes the size of the arguments and of the return value of a method.
      Parameters:
      desc - the descriptor of a method.
      Returns:
      the size of the arguments of the method (plus one for the implicit this argument), argSize, and the size of its return value, retSize, packed into a single
      int i = (argSize << 2) | retSize 
      (argSize is therefore equal to
      i >> 2 
      , and
      retSize 
      to
       @{code i & 0x03 }
               
      ).
    • getClassName

      @NonNull public abstract String getClassName()
      Returns the binary name of the class corresponding to this type. This method must not be used on method types.
    • getDescriptor

      @NonNull public final String getDescriptor()
      Returns the descriptor corresponding to this Java type.
    • getInternalName

      @NonNull public static String getInternalName(@NonNull Class<?> aClass)
      Returns the internal name of the given class. The internal name of a class is its fully qualified name, as returned by Class.getName(), where '.' are replaced by '/'.
      Parameters:
      aClass - an object or array class
    • getConstructorDescriptor

      @NonNull public static String getConstructorDescriptor(@NonNull Constructor<?> constructor)
      Returns the descriptor corresponding to the given constructor.
    • getMethodDescriptor

      @NonNull public static String getMethodDescriptor(@NonNull Method method)
      Returns the descriptor corresponding to the given method.
    • getSize

      public abstract @org.checkerframework.checker.index.qual.NonNegative int getSize()
      Returns the size of values of this type. This method must not be used for method types.
      Returns:
      the size of values of this type, i.e., 2 for long and double, 0 for void and 1 otherwise.
    • getOpcode

      public abstract int getOpcode(int opcode)
      Returns a JVM instruction opcode adapted to this Java type. This method must not be used for method types.
      Parameters:
      opcode - a JVM instruction opcode. This opcode must be one of ILOAD, ISTORE, IALOAD, IASTORE, IADD, ISUB, IMUL, IDIV, IREM, INEG, ISHL, ISHR, IUSHR, IAND, IOR, IXOR and IRETURN.
      Returns:
      an opcode that is similar to the given opcode, but adapted to this Java type. For example, if this type is float and opcode is IRETURN, this method returns FRETURN.
    • getLoadOpcode

      public abstract int getLoadOpcode()
    • getConstOpcode

      public abstract int getConstOpcode()
    • toString

      public final String toString()
      Returns a string representation of this type.
      Overrides:
      toString in class Object
      Returns:
      the descriptor of this type.