public interface

IJavaType

com.pnfsoftware.jeb.core.units.code.java.IJavaType

Class Overview

This interface is used to define a Java type.

Those objects can represent exact types or wildcard (imprecise) types. They are used at both the IR and at the AST level.

Summary

Constants
String JAVA_LANG_CLASS
String JAVA_LANG_ENUM
String JAVA_LANG_EXCEPTION
String JAVA_LANG_INVOKE_CALLSITE
String JAVA_LANG_INVOKE_METHODHANDLE
String JAVA_LANG_INVOKE_METHODTYPE
String JAVA_LANG_OBJECT
String JAVA_LANG_STRING
String JAVA_LANG_THROWABLE
Public Methods
abstract IJavaType asWildcardExt()
Retrieve an "extends" wildcard version of this type.
abstract IJavaType asWildcardSup()
Retrieve a "super" wildcard version of this type.
abstract boolean canSetType(IJavaType otherType, boolean useExternalTypeInfo)
Determine whether this type could be replaced by (as in, specialized) the provided other type.
abstract IJavaType compareAndGetMostPrecise(IJavaType other)
abstract boolean compareSimple(IJavaType t)
Simple comparison: are both types objects (incl.
abstract void format(DFormattingContext fctx)
Get a programmer's representation for that type.
abstract void formatArray(DFormattingContext fctx, IDExpression dim0)
abstract IJavaType getArrayElementType()
Get the simplest type of an array type, that is, the type of a 0-dimension array.
abstract IJavaType getArrayTypeDimensionBelow()
Get the type of an imaginary array with one dimension less than the current array.
abstract int getDimensions()
Get the dimension count of an array type.
abstract IJavaTypeFactory getFactory()
abstract String getName()
Get the internal representation.
abstract String getSignature()
Get the Java type name (internal form).
abstract int getSlotCount()
This method will throw if called on the void type!
abstract boolean isArray()
abstract boolean isBoolean()
abstract boolean isByte()
abstract boolean isChar()
abstract boolean isClassOrInterface()
abstract boolean isDefined()
abstract boolean isDetermined()
abstract boolean isDouble()
abstract boolean isDoubleRegister()
This method is deprecated. use isDoubleSlot() instead
abstract boolean isDoubleSlot()
abstract boolean isDoubleSlotWildcard()
Wildcard type for any type whose concrete representation requires two slots.
abstract boolean isFloat()
abstract boolean isFloatingPointType()
abstract boolean isGenericInteger()
isSpecificInteger() + BOOLEAN and the generic type SMALLINT.
abstract boolean isGenericObject()
This method is deprecated. use isGenericObjectWildcard() instead
abstract boolean isGenericObjectWildcard()
Wildcard type for any object.
abstract boolean isInt()
abstract boolean isJavaLangClass()
Convenience method.
abstract boolean isJavaLangObject()
Convenience method.
abstract boolean isJavaLangString()
Convenience method.
abstract boolean isLegal()
abstract boolean isLong()
abstract boolean isObject()
abstract boolean isObjectWildcardExtends()
abstract boolean isObjectWildcardSuper()
abstract boolean isPrimitive()
abstract boolean isShort()
abstract boolean isSingleRegister()
This method is deprecated. use isSingleSlot() instead
abstract boolean isSingleSlot()
abstract boolean isSingleSlotWildcard()
Wildcard type for any type whose concrete representation requires one slot.
abstract boolean isSmallInt()
abstract boolean isSmallIntegerWildcard()
Wildcard type for any small integer type (byte, char, short, int).
abstract boolean isSpecificInteger()
abstract boolean isStringType()
This method is deprecated. use isJavaLangString() instead
abstract boolean isUndefined()
abstract boolean isValidForRendering()
abstract boolean isVoid()
abstract boolean isWildcard()

Constants

public static final String JAVA_LANG_CLASS

Constant Value: "Ljava/lang/Class;"

public static final String JAVA_LANG_ENUM

Constant Value: "Ljava/lang/Enum;"

public static final String JAVA_LANG_EXCEPTION

Constant Value: "Ljava/lang/Exception;"

public static final String JAVA_LANG_INVOKE_CALLSITE

Constant Value: "Ljava/lang/invoke/CallSite;"

public static final String JAVA_LANG_INVOKE_METHODHANDLE

Constant Value: "Ljava/lang/invoke/MethodHandle;"

public static final String JAVA_LANG_INVOKE_METHODTYPE

Constant Value: "Ljava/lang/invoke/MethodType;"

public static final String JAVA_LANG_OBJECT

Constant Value: "Ljava/lang/Object;"

public static final String JAVA_LANG_STRING

Constant Value: "Ljava/lang/String;"

public static final String JAVA_LANG_THROWABLE

Constant Value: "Ljava/lang/Throwable;"

Public Methods

public abstract 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.

public abstract 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.

public abstract boolean canSetType (IJavaType otherType, boolean useExternalTypeInfo)

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, because List is already a specific type. However, if this type were to be ?_extends_List, the method would return true for any type extending List, including List itself or ArrayList.

Parameters
otherType another type
Returns
  • success indicator

public abstract IJavaType compareAndGetMostPrecise (IJavaType other)

public abstract boolean compareSimple (IJavaType t)

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.

public abstract void format (DFormattingContext fctx)

Get a programmer's representation for that type. Examples:
- top-level class Lcom/foo/B$la; becomes com.foo.B$la
- inner class Lcom/foo/Farm$Cow; becomes com.foo.Farm.Cow

Parameters
fctx sink and formatting context

public abstract void formatArray (DFormattingContext fctx, IDExpression dim0)

Parameters
fctx sink and formatting context

public abstract IJavaType getArrayElementType ()

Get the simplest type of an array type, that is, the type of a 0-dimension array.
Example: [[[I -> I

public abstract IJavaType getArrayTypeDimensionBelow ()

Get the type of an imaginary array with one dimension less than the current array.
Example: [[[I -> [[I

public abstract int getDimensions ()

Get the dimension count of an array type. This method will throw if this type is not an array.

public abstract IJavaTypeFactory getFactory ()

Returns
  • the type factory that created this type object

public abstract 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

public abstract String getSignature ()

Get the Java type name (internal form).

Returns
  • internal type name, using the L.../...; form

public abstract int getSlotCount ()

This method will throw if called on the void type!

Returns
  • 1 or 2

public abstract boolean isArray ()

Returns
  • true if this type is an array type

public abstract boolean isBoolean ()

Returns
  • true if this type is the boolean primitive

public abstract boolean isByte ()

Returns
  • true if this type is the byte primitive

public abstract boolean isChar ()

Returns
  • true if this type is the char primitive

public abstract boolean isClassOrInterface ()

Returns
  • true if this type is a class or interface type (not an array type, not a primitive)

public abstract boolean isDefined ()

Returns
  • true if anything but void or the single-slot or double-slot wildcard

public abstract boolean isDetermined ()

Returns
  • true if anything but void or a wildcard type

public abstract boolean isDouble ()

Returns
  • true if this type is the double primitive

public abstract boolean isDoubleRegister ()

This method is deprecated.
use isDoubleSlot() instead

public abstract boolean isDoubleSlot ()

Returns
  • true if the concrete representation of this type is stored in a two slots

public abstract boolean isDoubleSlotWildcard ()

Wildcard type for any type whose concrete representation requires two slots.

public abstract boolean isFloat ()

Returns
  • true if this type is the float primitive

public abstract boolean isFloatingPointType ()

Returns
  • true if float or double

public abstract boolean isGenericInteger ()

isSpecificInteger() + BOOLEAN and the generic type SMALLINT.

public abstract boolean isGenericObject ()

This method is deprecated.
use isGenericObjectWildcard() instead

public abstract boolean isGenericObjectWildcard ()

Wildcard type for any object.

public abstract boolean isInt ()

Returns
  • true if this type is the int primitive

public abstract boolean isJavaLangClass ()

Convenience method.

Returns
  • true if this type is java.lang.Class.

public abstract boolean isJavaLangObject ()

Convenience method.

Returns
  • true if this type is java.lang.Object.

public abstract boolean isJavaLangString ()

Convenience method.

Returns
  • true if this type is java.lang.String.

public abstract boolean isLegal ()

Returns
  • true if non-void

public abstract boolean isLong ()

Returns
  • true if this type is the long primitive

public abstract 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

public abstract boolean isObjectWildcardExtends ()

Returns
  • true if this type is a specialization wildcard: ? extends SomeType

public abstract boolean isObjectWildcardSuper ()

Returns
  • true if this type is a generalization wildcard: ? super SomeType

public abstract boolean isPrimitive ()

Returns
  • true if this type is a primitive

public abstract boolean isShort ()

Returns
  • true if this type is the short primitive

public abstract boolean isSingleRegister ()

This method is deprecated.
use isSingleSlot() instead

public abstract boolean isSingleSlot ()

Returns
  • true if the concrete representation of this type is stored in a single slot

public abstract boolean isSingleSlotWildcard ()

Wildcard type for any type whose concrete representation requires one slot.

public abstract boolean isSmallInt ()

Returns
  • true for BYTE, CHAR, SHORT, INT or SMALLINT (wildcard type for any of the previous small-integer types)

public abstract boolean isSmallIntegerWildcard ()

Wildcard type for any small integer type (byte, char, short, int).

public abstract boolean isSpecificInteger ()

Returns
  • true for byte, char, short, int or long (note: the small-int wildcard is NOT a specific integer)

public abstract boolean isStringType ()

This method is deprecated.
use isJavaLangString() instead

public abstract boolean isUndefined ()

Returns
  • true if void, the single-slot, or the double-slot wildcard

public abstract boolean isValidForRendering ()

public abstract boolean isVoid ()

Returns
  • true if this "type" is void (i.e. not a type, or the illegal type)

public abstract boolean isWildcard ()

Returns
  • true if small-int wildcard, single-slot wildcard, double-slot wildcard, generic-object wildcard