Class JavaType
java.lang.Object
mockit.asm.types.JavaType
- Direct Known Subclasses:
PrimitiveType, ReferenceType
A Java field or method type. This class can be used to make it easier to manipulate type and method descriptors.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intComputes the size of the arguments and of the return value of a method.static JavaType[]getArgumentTypes(String methodDescriptor) Returns the Java types corresponding to the argument types of the given method descriptor.abstract StringReturns the binary name of the class corresponding to this type.abstract intstatic StringgetConstructorDescriptor(Constructor<?> constructor) Returns the descriptor corresponding to the given constructor.final StringReturns the descriptor corresponding to this Java type.static StringgetInternalName(Class<?> aClass) Returns the internal name of the given class.abstract intstatic StringgetMethodDescriptor(Method method) Returns the descriptor corresponding to the given method.abstract intgetOpcode(int opcode) Returns a JVM instruction opcode adapted to this Java type.static JavaTypegetReturnType(String methodDescriptor) Returns the Java type corresponding to the return type of the given method descriptor.abstract @NonNegative intgetSize()Returns the size of values of this type.static JavaTypeReturns the Java type corresponding to the given type descriptor.final StringtoString()Returns a string representation of this type.
-
Method Details
-
getType
-
getArgumentTypes
-
getReturnType
-
getArgumentsAndReturnSizes
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
thisargument),argSize, and the size of its return value,retSize, packed into a single
(int i = (argSize << 2) | retSizeargSizeis therefore equal to
, andi >> 2
toretSize@{code i & 0x03 }).
-
getClassName
Returns the binary name of the class corresponding to this type. This method must not be used on method types. -
getDescriptor
Returns the descriptor corresponding to this Java type. -
getInternalName
-
getConstructorDescriptor
Returns the descriptor corresponding to the given constructor. -
getMethodDescriptor
-
getSize
public abstract @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
longanddouble, 0 forvoidand 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
floatandopcodeis IRETURN, this method returns FRETURN.
-
getLoadOpcode
public abstract int getLoadOpcode() -
getConstOpcode
public abstract int getConstOpcode() -
toString
-