Package mockit.asm.types
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 int
Computes 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 String
Returns the binary name of the class corresponding to this type.abstract int
static String
getConstructorDescriptor
(Constructor<?> constructor) Returns the descriptor corresponding to the given constructor.final String
Returns the descriptor corresponding to this Java type.static String
getInternalName
(Class<?> aClass) Returns the internal name of the given class.abstract int
static String
getMethodDescriptor
(Method method) Returns the descriptor corresponding to the given method.abstract int
getOpcode
(int opcode) Returns a JVM instruction opcode adapted to this Java type.static JavaType
getReturnType
(String methodDescriptor) Returns the Java type corresponding to the return type of the given method descriptor.abstract @org.checkerframework.checker.index.qual.NonNegative int
getSize()
Returns the size of values of this type.static JavaType
Returns the Java type corresponding to the given type descriptor.final String
toString()
Returns a string representation of this type.
-
Method Details
-
getType
Returns the Java type corresponding to the given type descriptor.- Parameters:
typeDescriptor
- a field or method type descriptor.
-
getArgumentTypes
Returns the Java types corresponding to the argument types of the given method descriptor. -
getReturnType
Returns the Java type corresponding to the return type of the given method descriptor. -
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
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
, 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
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
Returns the descriptor corresponding to the given constructor. -
getMethodDescriptor
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
anddouble
, 0 forvoid
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
andopcode
is IRETURN, this method returns FRETURN.
-
getLoadOpcode
public abstract int getLoadOpcode() -
getConstOpcode
public abstract int getConstOpcode() -
toString
Returns a string representation of this type.
-