Package com.android.dx.rop.type
Class Type
java.lang.Object
com.android.dx.rop.type.Type
- All Implemented Interfaces:
TypeBearer
,ToHuman
,Comparable<Type>
Representation of a value type, such as may appear in a field, in a
local, on a stack, or in a method descriptor. Instances of this
class are generally interned and may be usefully compared with each
other using
==
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final Type
non-null;
instance representingjava.lang.annotation.Annotation
static final Type
non-null;
instance representingboolean
static final Type
non-null;
instance representingboolean[]
static final Type
non-null;
instance representingjava.lang.Boolean
; the suffix on the name helps disambiguate this from the instance representing a primitive typestatic final int
basic type constant for a return addressstatic final int
basic type constant forboolean
static final int
basic type constant forbyte
static final int
basic type constant forchar
static final int
count of basic type constantsstatic final int
basic type constant fordouble
static final int
basic type constant forfloat
static final int
basic type constant forint
static final int
basic type constant forlong
static final int
basic type constant forObject
static final int
basic type constant forshort
static final int
basic type constant forvoid
static final Type
non-null;
instance representingbyte
static final Type
non-null;
instance representingbyte[]
static final Type
non-null;
instance representingjava.lang.Byte
; the suffix on the name helps disambiguate this from the instance representing a primitive typestatic final Type
non-null;
instance representingchar
static final Type
non-null;
instance representingchar[]
static final Type
non-null;
instance representingjava.lang.Character
; the suffix on the name helps disambiguate this from the instance representing a primitive typestatic final Type
non-null;
instance representingjava.lang.Class
static final Type
non-null;
instance representingjava.lang.Cloneable
static final Type
non-null;
instance representingdouble
static final Type
non-null;
instance representingdouble[]
static final Type
non-null;
instance representingjava.lang.Double
; the suffix on the name helps disambiguate this from the instance representing a primitive typestatic final Type
non-null;
instance representingfloat
static final Type
non-null;
instance representingfloat[]
static final Type
non-null;
instance representingjava.lang.Float
; the suffix on the name helps disambiguate this from the instance representing a primitive typestatic final Type
non-null;
instance representingint
static final Type
non-null;
instance representingint[]
static final Type
non-null;
instance representingjava.lang.Integer
; the suffix on the name helps disambiguate this from the instance representing a primitive typestatic final Type
non-null;
instance representing a known-null
static final Type
non-null;
instance representinglong
static final Type
non-null;
instance representinglong[]
static final Type
non-null;
instance representingjava.lang.Long
; the suffix on the name helps disambiguate this from the instance representing a primitive typestatic final Type
non-null;
instance representingjava.lang.invoke.MethodHandle
static final Type
non-null;
instance representingjava.lang.invoke.MethodType
static final Type
non-null;
instance representingjava.lang.Object
static final Type
non-null;
instance representingObject[]
static final Type
non-null;
instance representing a subroutine return addressstatic final Type
non-null;
instance representingjava.io.Serializable
static final Type
non-null;
instance representingshort
static final Type
non-null;
instance representingshort[]
static final Type
non-null;
instance representingjava.lang.Short
; the suffix on the name helps disambiguate this from the instance representing a primitive typestatic final Type
non-null;
instance representingjava.lang.String
static final Type
non-null;
instance representingjava.lang.Throwable
static final Type
non-null;
instance representingjava.lang.invoke.VarHandle
static final Type
non-null;
instance representingvoid
static final Type
non-null;
instance representingjava.lang.Void
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
Method Summary
Modifier and TypeMethodDescriptionasUninitialized
(int newAt) Returns a new interned instance which is identical to this one, except it is indicated as uninitialized and allocated at the given bytecode index.static void
int
boolean
Gets the type corresponding to an array of this type.int
Gets the basic type corresponding to this instance's frame type.int
Gets the basic type corresponding to this instance.int
Gets the category.Gets the name of the class this type corresponds to, in internal form.Gets the component type of this type.Gets the descriptor.Gets the frame type corresponding to this type.Gets the initialized type corresponding to this instance, but only if this instance is in fact an uninitialized object type.int
getNewAt()
Gets the bytecode index at which this uninitialized type was allocated.getType()
Gets the type associated with this instance.int
hashCode()
static Type
Returns the unique instance corresponding to the type with the given descriptor.static Type
internClassName
(String name) Returns the unique instance corresponding to the type of the class with the given name.static Type
internReturnType
(String descriptor) Returns the unique instance corresponding to the type with the given descriptor, allowing"V"
to return the type forvoid
.boolean
isArray()
Gets whether this type is an array type.boolean
Gets whether this type is an array type or is a known-null, and hence is compatible with array types.boolean
Returns whether or not this is a category 1 type.boolean
Returns whether or not this is a category 2 type.boolean
Returns whether this instance represents a constant value.boolean
Gets whether this type is "intlike." An intlike type is one which, when placed on a stack or in a local, is automatically converted to anint
.boolean
Gets whether this type is a primitive type.boolean
Gets whether this type is a normal reference type.boolean
Gets whether this type represents an uninitialized instance.toHuman()
Return the "human" string form of this instance.toString()
-
Field Details
-
BT_VOID
public static final int BT_VOIDbasic type constant forvoid
- See Also:
-
BT_BOOLEAN
public static final int BT_BOOLEANbasic type constant forboolean
- See Also:
-
BT_BYTE
public static final int BT_BYTEbasic type constant forbyte
- See Also:
-
BT_CHAR
public static final int BT_CHARbasic type constant forchar
- See Also:
-
BT_DOUBLE
public static final int BT_DOUBLEbasic type constant fordouble
- See Also:
-
BT_FLOAT
public static final int BT_FLOATbasic type constant forfloat
- See Also:
-
BT_INT
public static final int BT_INTbasic type constant forint
- See Also:
-
BT_LONG
public static final int BT_LONGbasic type constant forlong
- See Also:
-
BT_SHORT
public static final int BT_SHORTbasic type constant forshort
- See Also:
-
BT_OBJECT
public static final int BT_OBJECTbasic type constant forObject
- See Also:
-
BT_ADDR
public static final int BT_ADDRbasic type constant for a return address- See Also:
-
BT_COUNT
public static final int BT_COUNTcount of basic type constants- See Also:
-
BOOLEAN
non-null;
instance representingboolean
-
BYTE
non-null;
instance representingbyte
-
CHAR
non-null;
instance representingchar
-
DOUBLE
non-null;
instance representingdouble
-
FLOAT
non-null;
instance representingfloat
-
INT
non-null;
instance representingint
-
LONG
non-null;
instance representinglong
-
SHORT
non-null;
instance representingshort
-
VOID
non-null;
instance representingvoid
-
KNOWN_NULL
non-null;
instance representing a known-null
-
RETURN_ADDRESS
non-null;
instance representing a subroutine return address -
ANNOTATION
non-null;
instance representingjava.lang.annotation.Annotation
-
CLASS
non-null;
instance representingjava.lang.Class
-
CLONEABLE
non-null;
instance representingjava.lang.Cloneable
-
METHOD_HANDLE
non-null;
instance representingjava.lang.invoke.MethodHandle
-
METHOD_TYPE
non-null;
instance representingjava.lang.invoke.MethodType
-
VAR_HANDLE
non-null;
instance representingjava.lang.invoke.VarHandle
-
OBJECT
non-null;
instance representingjava.lang.Object
-
SERIALIZABLE
non-null;
instance representingjava.io.Serializable
-
STRING
non-null;
instance representingjava.lang.String
-
THROWABLE
non-null;
instance representingjava.lang.Throwable
-
BOOLEAN_CLASS
non-null;
instance representingjava.lang.Boolean
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
BYTE_CLASS
non-null;
instance representingjava.lang.Byte
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
CHARACTER_CLASS
non-null;
instance representingjava.lang.Character
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
DOUBLE_CLASS
non-null;
instance representingjava.lang.Double
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
FLOAT_CLASS
non-null;
instance representingjava.lang.Float
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
INTEGER_CLASS
non-null;
instance representingjava.lang.Integer
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
LONG_CLASS
non-null;
instance representingjava.lang.Long
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
SHORT_CLASS
non-null;
instance representingjava.lang.Short
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
VOID_CLASS
non-null;
instance representingjava.lang.Void
; the suffix on the name helps disambiguate this from the instance representing a primitive type -
BOOLEAN_ARRAY
non-null;
instance representingboolean[]
-
BYTE_ARRAY
non-null;
instance representingbyte[]
-
CHAR_ARRAY
non-null;
instance representingchar[]
-
DOUBLE_ARRAY
non-null;
instance representingdouble[]
-
FLOAT_ARRAY
non-null;
instance representingfloat[]
-
INT_ARRAY
non-null;
instance representingint[]
-
LONG_ARRAY
non-null;
instance representinglong[]
-
OBJECT_ARRAY
non-null;
instance representingObject[]
-
SHORT_ARRAY
non-null;
instance representingshort[]
-
-
Method Details
-
intern
Returns the unique instance corresponding to the type with the given descriptor. See vmspec-2 sec4.3.2 for details on the field descriptor syntax. This method does not allow"V"
(that is, typevoid
) as a valid descriptor.- Parameters:
descriptor
-non-null;
the descriptor- Returns:
non-null;
the corresponding instance- Throws:
IllegalArgumentException
- thrown if the descriptor has invalid syntax
-
internReturnType
Returns the unique instance corresponding to the type with the given descriptor, allowing"V"
to return the type forvoid
. Other than that one caveat, this method is identical tointern(java.lang.String)
.- Parameters:
descriptor
-non-null;
the descriptor- Returns:
non-null;
the corresponding instance- Throws:
IllegalArgumentException
- thrown if the descriptor has invalid syntax
-
internClassName
Returns the unique instance corresponding to the type of the class with the given name. Calling this method is equivalent to callingintern(name)
ifname
begins with"["
and callingintern("L" + name + ";")
in all other cases.- Parameters:
name
-non-null;
the name of the class whose type is desired- Returns:
non-null;
the corresponding type- Throws:
IllegalArgumentException
- thrown if the name has invalid syntax
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<Type>
-
toString
-
toHuman
Return the "human" string form of this instance. This is generally less "debuggy" thantoString()
. -
getType
Gets the type associated with this instance.- Specified by:
getType
in interfaceTypeBearer
- Returns:
non-null;
the type
-
getFrameType
Gets the frame type corresponding to this type. This method returnsthis
, except ifisIntlike()
on the underlying type returnstrue
but the underlying type is not in factINT
, in which case this method returns an instance whose underlying type isINT
.- Specified by:
getFrameType
in interfaceTypeBearer
- Returns:
non-null;
the frame type for this instance
-
getBasicType
public int getBasicType()Gets the basic type corresponding to this instance.- Specified by:
getBasicType
in interfaceTypeBearer
- Returns:
- the basic type; one of the
BT_*
constants defined byType
-
getBasicFrameType
public int getBasicFrameType()Gets the basic type corresponding to this instance's frame type. This is equivalent togetFrameType().getBasicType()
, and is the same as callinggetFrameType()
unless this instance is an int-like type, in which case this method returnsBT_INT
.- Specified by:
getBasicFrameType
in interfaceTypeBearer
- Returns:
- the basic frame type; one of the
BT_*
constants defined byType
- See Also:
-
isConstant
public boolean isConstant()Returns whether this instance represents a constant value.- Specified by:
isConstant
in interfaceTypeBearer
- Returns:
true
if this instance represents a constant value andfalse
if not
-
getDescriptor
Gets the descriptor.- Returns:
non-null;
the descriptor
-
getClassName
Gets the name of the class this type corresponds to, in internal form. This method is only valid if this instance is for a normal reference type (that is, a reference type and additionally not a return address).- Returns:
non-null;
the internal-form class name
-
getCategory
public int getCategory()Gets the category. Most instances are category 1.long
anddouble
are the only category 2 types.- Returns:
- the category
- See Also:
-
isCategory1
public boolean isCategory1()Returns whether or not this is a category 1 type.- Returns:
- whether or not this is a category 1 type
- See Also:
-
isCategory2
public boolean isCategory2()Returns whether or not this is a category 2 type.- Returns:
- whether or not this is a category 2 type
- See Also:
-
isIntlike
public boolean isIntlike()Gets whether this type is "intlike." An intlike type is one which, when placed on a stack or in a local, is automatically converted to anint
.- Returns:
- whether this type is "intlike"
-
isPrimitive
public boolean isPrimitive()Gets whether this type is a primitive type. All types are either primitive or reference types.- Returns:
- whether this type is primitive
-
isReference
public boolean isReference()Gets whether this type is a normal reference type. A normal reference type is a reference type that is not a return address. This method is just convenient shorthand forgetBasicType() == Type.BT_OBJECT
.- Returns:
- whether this type is a normal reference type
-
isArray
public boolean isArray()Gets whether this type is an array type. If this method returnstrue
, then it is safe to usegetComponentType()
to determine the component type.- Returns:
- whether this type is an array type
-
isArrayOrKnownNull
public boolean isArrayOrKnownNull()Gets whether this type is an array type or is a known-null, and hence is compatible with array types.- Returns:
- whether this type is an array type
-
isUninitialized
public boolean isUninitialized()Gets whether this type represents an uninitialized instance. An uninitialized instance is what one gets back from thenew
opcode, and remains uninitialized until a valid constructor is invoked on it.- Returns:
- whether this type is "uninitialized"
-
getNewAt
public int getNewAt()Gets the bytecode index at which this uninitialized type was allocated. This returnsInteger.MAX_VALUE
if this type is an uninitialized incoming parameter (i.e., thethis
of an<init>
method) or-1
if this type is in fact initialized.- Returns:
>= -1;
the allocation bytecode index
-
getInitializedType
Gets the initialized type corresponding to this instance, but only if this instance is in fact an uninitialized object type.- Returns:
non-null;
the initialized type
-
getArrayType
Gets the type corresponding to an array of this type.- Returns:
non-null;
the array type
-
getComponentType
Gets the component type of this type. This method is only valid on array types.- Returns:
non-null;
the component type
-
asUninitialized
Returns a new interned instance which is identical to this one, except it is indicated as uninitialized and allocated at the given bytecode index. This instance must be an initialized object type.- Parameters:
newAt
->= 0;
the allocation bytecode index- Returns:
non-null;
an appropriately-constructed instance
-
clearInternTable
public static void clearInternTable()
-