Interface IJavaType
Those objects can represent exact types or wildcard (imprecise) types. They are used at both the IR and at the AST level.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionRetrieve an "extends" wildcard version of this type.Retrieve a "super" wildcard version of this type.boolean
canSetType
(IJavaType otherType, boolean useExternalTypeInfo) Determine whether this type could be replaced by (as in, specialized) the provided other type.boolean
Simple comparison: are both types objects (incl.void
format
(DFormattingContext fctx) Get a programmer's representation for that type.void
formatArray
(DFormattingContext fctx, IDExpression dim0) Get the simplest type of an array type, that is, the type of a 0-dimension array.
Example: [[[I -> IGet the type of an imaginary array with one dimension less than the current array.
Example: [[[I -> [[Iint
Get the dimension count of an array type.int
getName()
Get the internal representation.Get the Java type name (internal form).int
This method will throw if called on thevoid
type!boolean
isArray()
boolean
boolean
isByte()
boolean
isChar()
boolean
boolean
boolean
boolean
isDouble()
boolean
boolean
Wildcard type for any type whose concrete representation requires two slots.boolean
isFloat()
boolean
boolean
isSpecificInteger()
+ BOOLEAN and the generic type SMALLINT.boolean
Wildcard type for any object.boolean
isInt()
boolean
Convenience method.boolean
Convenience method.boolean
Convenience method.boolean
isLegal()
boolean
isLong()
boolean
isObject()
boolean
boolean
boolean
boolean
isShort()
boolean
boolean
Wildcard type for any type whose concrete representation requires one slot.boolean
boolean
Wildcard type for any small integer type (byte, char, short, int).boolean
boolean
boolean
boolean
isVoid()
boolean
-
Field Details
-
JAVA_LANG_OBJECT
- See Also:
-
JAVA_LANG_STRING
- See Also:
-
JAVA_LANG_CLASS
- See Also:
-
JAVA_LANG_ENUM
- See Also:
-
JAVA_LANG_EXCEPTION
- See Also:
-
JAVA_LANG_THROWABLE
- See Also:
-
JAVA_LANG_INVOKE_METHODTYPE
- See Also:
-
JAVA_LANG_INVOKE_METHODHANDLE
- See Also:
-
JAVA_LANG_INVOKE_CALLSITE
- See Also:
-
-
Method Details
-
getFactory
IJavaTypeFactory getFactory()- Returns:
- the type factory that created this type object
-
isVoid
boolean isVoid()- Returns:
- true if this "type" is
void
(i.e. not a type, or the illegal type)
-
isPrimitive
boolean isPrimitive()- Returns:
- true if this type is a primitive
-
isBoolean
boolean isBoolean()- Returns:
- true if this type is the
boolean
primitive
-
isByte
boolean isByte()- Returns:
- true if this type is the
byte
primitive
-
isChar
boolean isChar()- Returns:
- true if this type is the
char
primitive
-
isShort
boolean isShort()- Returns:
- true if this type is the
short
primitive
-
isInt
boolean isInt()- Returns:
- true if this type is the
int
primitive
-
isLong
boolean isLong()- Returns:
- true if this type is the
long
primitive
-
isFloat
boolean isFloat()- Returns:
- true if this type is the
float
primitive
-
isDouble
boolean isDouble()- Returns:
- true if this type is the
double
primitive
-
isSingleSlotWildcard
boolean isSingleSlotWildcard()Wildcard type for any type whose concrete representation requires one slot.- Returns:
-
isDoubleSlotWildcard
boolean isDoubleSlotWildcard()Wildcard type for any type whose concrete representation requires two slots.- Returns:
-
isSmallIntegerWildcard
boolean isSmallIntegerWildcard()Wildcard type for any small integer type (byte, char, short, int).- Returns:
-
isGenericObjectWildcard
boolean isGenericObjectWildcard()Wildcard type for any object.- Returns:
-
isObjectWildcardExtends
boolean isObjectWildcardExtends()- Returns:
- true if this type is a specialization wildcard:
? extends SomeType
-
isObjectWildcardSuper
boolean isObjectWildcardSuper()- Returns:
- true if this type is a generalization wildcard:
? super SomeType
-
isObject
boolean isObject()- Returns:
- true if this type is an object type: could be the generic-object wildcard, a specific class or interface type, an array type
-
isClassOrInterface
boolean isClassOrInterface()- Returns:
- true if this type is a class or interface type (not an array type, not a primitive)
-
isArray
boolean isArray()- Returns:
- true if this type is an array type
-
getDimensions
int getDimensions()Get the dimension count of an array type. This method will throw if this type is not an array.- Returns:
-
getArrayElementType
IJavaType getArrayElementType()Get the simplest type of an array type, that is, the type of a 0-dimension array.
Example: [[[I -> I- Returns:
-
getArrayTypeDimensionBelow
IJavaType getArrayTypeDimensionBelow()Get the type of an imaginary array with one dimension less than the current array.
Example: [[[I -> [[I- Returns:
-
getName
String getName()Get the internal representation. Never fail. If the type is a wildcard reference, the type reference without wildcard is returned (example: on type? extends T
, this method will return "T").- Returns:
- internal representation of the type name
-
getSignature
String getSignature()Get the Java type name (internal form).- Returns:
- internal type name, using the
L.../...;
form
-
isJavaLangObject
boolean isJavaLangObject()Convenience method.- Returns:
- true if this type is
java.lang.Object
.
-
isJavaLangClass
boolean isJavaLangClass()Convenience method.- Returns:
- true if this type is
java.lang.Class
.
-
isJavaLangString
boolean isJavaLangString()Convenience method.- Returns:
- true if this type is
java.lang.String
.
-
isFloatingPointType
boolean isFloatingPointType()- Returns:
- true if
float
ordouble
-
getEncodingBitsize
int getEncodingBitsize()- Returns:
- the memory bitsize required to store such a type (or type-reference, for an object type), such as 1 for a boolean, 8 for a char, 16 for a short/char32 for an int/float/ref, 64 for a long/double, etc.
-
isSingleSlot
boolean isSingleSlot()- Returns:
- true if the concrete representation of this type is stored in a single slot
-
isDoubleSlot
boolean isDoubleSlot()- Returns:
- true if the concrete representation of this type is stored in a two slots
-
isLegal
boolean isLegal()- Returns:
- true if non-void
-
isUndefined
boolean isUndefined()- Returns:
- true if void, the single-slot, or the double-slot wildcard
-
isDefined
boolean isDefined()- Returns:
- true if anything but void or the single-slot or double-slot wildcard
-
isDetermined
boolean isDetermined()- Returns:
- true if anything but void or a wildcard type
-
isWildcard
boolean isWildcard()- Returns:
- true if small-int wildcard, single-slot wildcard, double-slot wildcard, generic-object wildcard
-
asWildcardSup
IJavaType asWildcardSup()Retrieve a "super" wildcard version of this type.Watch out! For super-wildcards, this method returns the same type. For extends-wildcards, this method does NOT return the generic object type. It returns the super-wildcard of the non-wildcard type.
- Returns:
-
asWildcardExt
IJavaType asWildcardExt()Retrieve an "extends" wildcard version of this type.Watch out! For extends-wildcards, this method returns the same type. For super-wildcards, this method does NOT return the generic object type. It returns the extends-wildcard of the non-wildcard type.
- Returns:
-
getSlotCount
int getSlotCount()This method will throw if called on thevoid
type!- Returns:
- 1 or 2
-
isSmallInt
boolean isSmallInt()- Returns:
- true for
BYTE, CHAR, SHORT, INT
orSMALLINT
(wildcard type for any of the previous small-integer types)
-
isSpecificInteger
boolean isSpecificInteger()- Returns:
- true for byte, char, short, int or long (note: the small-int wildcard is NOT a specific integer)
-
isGenericInteger
boolean isGenericInteger()isSpecificInteger()
+ BOOLEAN and the generic type SMALLINT.- Returns:
-
compareSimple
Simple comparison: are both types objects (incl. arrays) or ints, etc.Note 1: comparing a String to an ArrayList or an array of int would return true.
Note 2: comparing an int to a smallint would return false</>.- Parameters:
t
-- Returns:
-
canSetType
Determine whether this type could be replaced by (as in, specialized) the provided other type. Unless the other type is the same as this type, this method will fail if this type is not a wildcard.For objects, do not confuse this method with type hierarchy checkers. Example: if this type is
List
, this method will return false if the other type is e.g.ArrayList
, becauseList
is already a specific type. However, if this type were to be?_extends_List
, the method would return true for any type extendingList
, includingList
itself orArrayList
.- Parameters:
otherType
- another typeuseExternalTypeInfo
-- Returns:
- success indicator
-
compareAndGetMostPrecise
- Parameters:
other
-- Returns:
-
isValidForRendering
boolean isValidForRendering()- Returns:
-
format
Get a programmer's representation for that type. Examples:
- top-level classLcom/foo/B$la;
becomescom.foo.B$la
- inner classLcom/foo/Farm$Cow;
becomescom.foo.Farm.Cow
- Parameters:
fctx
- sink and formatting context
-
formatArray
- Parameters:
fctx
- sink and formatting contextdim0
-
-