Class TypeReference

java.lang.Object
com.ibm.wala.types.TypeReference
All Implemented Interfaces:
Serializable

public final class TypeReference extends Object implements Serializable
A class to represent the reference in a class file to some type (class, primitive or array). A type reference is uniquely defined by
  • an initiating class loader
  • a type name
Resolving a TypeReference to a Type can be an expensive operation. Therefore we canonicalize TypeReference instances and cache the result of resolution.
See Also:
  • Field Details

    • BooleanName

      public static final TypeName BooleanName
    • BooleanTypeCode

      public static final byte BooleanTypeCode
      See Also:
    • Boolean

      public static final TypeReference Boolean
    • ByteName

      public static final TypeName ByteName
    • ByteTypeCode

      public static final byte ByteTypeCode
      See Also:
    • Byte

      public static final TypeReference Byte
    • CharName

      public static final TypeName CharName
    • CharTypeCode

      public static final byte CharTypeCode
      See Also:
    • Char

      public static final TypeReference Char
    • DoubleName

      public static final TypeName DoubleName
    • DoubleTypeCode

      public static final byte DoubleTypeCode
      See Also:
    • Double

      public static final TypeReference Double
    • FloatName

      public static final TypeName FloatName
    • FloatTypeCode

      public static final byte FloatTypeCode
      See Also:
    • Float

      public static final TypeReference Float
    • IntName

      public static final TypeName IntName
    • IntTypeCode

      public static final byte IntTypeCode
      See Also:
    • Int

      public static final TypeReference Int
    • LongName

      public static final TypeName LongName
    • LongTypeCode

      public static final byte LongTypeCode
      See Also:
    • Long

      public static final TypeReference Long
    • ShortName

      public static final TypeName ShortName
    • ShortTypeCode

      public static final byte ShortTypeCode
      See Also:
    • Short

      public static final TypeReference Short
    • VoidName

      public static final TypeName VoidName
    • VoidTypeCode

      public static final byte VoidTypeCode
      See Also:
    • Void

      public static final TypeReference Void
    • OtherPrimitiveTypeCode

      public static final byte OtherPrimitiveTypeCode
      See Also:
    • BooleanArray

      public static final TypeReference BooleanArray
    • ByteArray

      public static final TypeReference ByteArray
    • CharArray

      public static final TypeReference CharArray
    • DoubleArray

      public static final TypeReference DoubleArray
    • FloatArray

      public static final TypeReference FloatArray
    • IntArray

      public static final TypeReference IntArray
    • LongArray

      public static final TypeReference LongArray
    • ShortArray

      public static final TypeReference ShortArray
    • JavaLangArithmeticException

      public static final TypeReference JavaLangArithmeticException
    • JavaLangArrayStoreException

      public static final TypeReference JavaLangArrayStoreException
    • JavaLangArrayIndexOutOfBoundsException

      public static final TypeReference JavaLangArrayIndexOutOfBoundsException
    • JavaLangClass

      public static final TypeReference JavaLangClass
    • JavaLangInvokeMethodHandle

      public static final TypeReference JavaLangInvokeMethodHandle
    • JavaLangInvokeMethodHandlesLookup

      public static final TypeReference JavaLangInvokeMethodHandlesLookup
    • JavaLangInvokeMethodType

      public static final TypeReference JavaLangInvokeMethodType
    • JavaLangClassCastException

      public static final TypeReference JavaLangClassCastException
    • JavaLangComparable

      public static final TypeReference JavaLangComparable
    • JavaLangReflectConstructor

      public static final TypeReference JavaLangReflectConstructor
    • JavaLangReflectMethod

      public static final TypeReference JavaLangReflectMethod
    • JavaLangEnum

      public static final TypeReference JavaLangEnum
    • JavaLangError

      public static final TypeReference JavaLangError
    • JavaLangException

      public static final TypeReference JavaLangException
    • JavaLangNegativeArraySizeException

      public static final TypeReference JavaLangNegativeArraySizeException
    • JavaLangNullPointerException

      public static final TypeReference JavaLangNullPointerException
    • JavaLangRuntimeException

      public static final TypeReference JavaLangRuntimeException
    • JavaLangClassNotFoundException

      public static final TypeReference JavaLangClassNotFoundException
    • JavaLangOutOfMemoryError

      public static final TypeReference JavaLangOutOfMemoryError
    • JavaLangExceptionInInitializerError

      public static final TypeReference JavaLangExceptionInInitializerError
    • JavaLangObject

      public static final TypeReference JavaLangObject
    • JavaLangStackTraceElement

      public static final TypeReference JavaLangStackTraceElement
    • JavaLangString

      public static final TypeReference JavaLangString
    • JavaLangStringBuffer

      public static final TypeReference JavaLangStringBuffer
    • JavaLangStringBuilder

      public static final TypeReference JavaLangStringBuilder
    • JavaLangThread

      public static final TypeReference JavaLangThread
    • JavaLangThrowable

      public static final TypeReference JavaLangThrowable
    • JavaLangCloneableName

      public static final TypeName JavaLangCloneableName
    • JavaLangCloneable

      public static final TypeReference JavaLangCloneable
    • JavaLangSystem

      public static final TypeReference JavaLangSystem
    • JavaLangInteger

      public static final TypeReference JavaLangInteger
    • JavaLangBoolean

      public static final TypeReference JavaLangBoolean
    • JavaLangDouble

      public static final TypeReference JavaLangDouble
    • JavaLangFloat

      public static final TypeReference JavaLangFloat
    • JavaLangShort

      public static final TypeReference JavaLangShort
    • JavaLangLong

      public static final TypeReference JavaLangLong
    • JavaLangByte

      public static final TypeReference JavaLangByte
    • JavaLangCharacter

      public static final TypeReference JavaLangCharacter
    • JavaIoSerializableName

      public static final TypeName JavaIoSerializableName
    • JavaIoSerializable

      public static final TypeReference JavaIoSerializable
    • JavaUtilCollection

      public static final TypeReference JavaUtilCollection
    • JavaUtilMap

      public static final TypeReference JavaUtilMap
    • JavaUtilHashSet

      public static final TypeReference JavaUtilHashSet
    • JavaUtilSet

      public static final TypeReference JavaUtilSet
    • JavaUtilEnum

      public static final TypeReference JavaUtilEnum
    • JavaUtilIterator

      public static final TypeReference JavaUtilIterator
    • JavaUtilVector

      public static final TypeReference JavaUtilVector
    • ClassTypeCode

      public static final byte ClassTypeCode
      See Also:
    • ArrayTypeCode

      public static final byte ArrayTypeCode
      See Also:
    • PointerTypeCode

      public static final byte PointerTypeCode
      See Also:
    • ReferenceTypeCode

      public static final byte ReferenceTypeCode
      See Also:
    • Null

      public static final TypeReference Null
    • Unknown

      public static final TypeReference Unknown
    • LambdaMetaFactory

      public static final TypeReference LambdaMetaFactory
  • Method Details

    • makePrimitive

      public static TypeReference makePrimitive(ClassLoaderReference cl, TypeName n)
    • isPrimitiveType

      public static boolean isPrimitiveType(TypeName name)
      Could name a represent a primitive type?
    • findOrCreate

      public static TypeReference findOrCreate(ClassLoaderReference cl, TypeName typeName)
      Find or create the canonical TypeReference instance for the given pair.
      Parameters:
      cl - the classloader (defining/initiating depending on usage)
    • findOrCreate

      public static TypeReference findOrCreate(ClassLoaderReference cl, String typeName)
      Find or create the canonical TypeReference instance for the given pair.
      Parameters:
      cl - the classloader (defining/initiating depending on usage)
      typeName - something like "Ljava/util/Arrays"
    • find

      public static TypeReference find(ClassLoaderReference cl, String typeName)
    • find

      public static TypeReference find(ClassLoaderReference cl, TypeName typeName)
      Find the canonical TypeReference instance for the given pair. May return null.
      Parameters:
      cl - the classloader (defining/initiating depending on usage)
    • findOrCreateArrayOf

      public static TypeReference findOrCreateArrayOf(TypeReference t)
    • findOrCreateReferenceTo

      public static TypeReference findOrCreateReferenceTo(TypeReference t)
    • findOrCreatePointerTo

      public static TypeReference findOrCreatePointerTo(TypeReference t)
    • getClassLoader

      public ClassLoaderReference getClassLoader()
      Returns:
      the classloader component of this type reference
    • getName

      public TypeName getName()
      Returns:
      the type name component of this type reference
    • getArrayElementType

      public TypeReference getArrayElementType()
      TODO: specialized form of TypeReference for arrays, please. Get the element type of for this array type.
    • getArrayTypeForElementType

      public TypeReference getArrayTypeForElementType()
      Get array type corresponding to "this" array element type.
    • getDerivedMask

      public int getDerivedMask()
      Return the dimensionality of the type. By convention, class types have dimensionality 0, primitives -1, and arrays the number of [ in their descriptor.
    • getInnermostElementType

      public TypeReference getInnermostElementType()
      Return the innermost element type reference for an array
    • isClassType

      public boolean isClassType()
      Does 'this' refer to a class?
    • isArrayType

      public boolean isArrayType()
      Does 'this' refer to an array?
    • isPrimitiveType

      public boolean isPrimitiveType()
      Does 'this' refer to a primitive type
    • isReferenceType

      public boolean isReferenceType()
      Does 'this' refer to a reference type
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      TypeReferences are canonical. However, note that two TypeReferences can be non-equal, yet still represent the same IClass.

      For example, the there can be two TypeReferences <Application,java.lang.Object> and <Primordial,java.lang.Object>. These two TypeReference are NOT equal(), but they both represent the IClass which is named <Primordial,java.lang.Object>

      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • findOrCreateClass

      public static TypeReference findOrCreateClass(ClassLoaderReference loader, String packageName, String className)
    • getDimensionality

      public int getDimensionality()