org.eclipse.jdt.internal.compiler.lookup
Class TypeBinding

java.lang.Object
  extended by org.eclipse.jdt.internal.compiler.lookup.Binding
      extended by org.eclipse.jdt.internal.compiler.lookup.TypeBinding
Direct Known Subclasses:
ArrayBinding, BaseTypeBinding, ReferenceBinding

public abstract class TypeBinding
extends Binding


Field Summary
static BaseTypeBinding BOOLEAN
           
static BaseTypeBinding BYTE
           
static BaseTypeBinding CHAR
           
static BaseTypeBinding DOUBLE
           
static BaseTypeBinding FLOAT
           
 int id
           
static BaseTypeBinding INT
          Base type definitions
static BaseTypeBinding LONG
           
static BaseTypeBinding NULL
           
static BaseTypeBinding SHORT
           
 long tagBits
           
static BaseTypeBinding VOID
           
 
Fields inherited from class org.eclipse.jdt.internal.compiler.lookup.Binding
ANY_EXCEPTION, ARRAY_TYPE, BASE_TYPE, FIELD, GENERIC_TYPE, IMPORT, INTERSECTION_TYPE, LOCAL, METHOD, NO_ANNOTATIONS, NO_ELEMENT_VALUE_PAIRS, NO_EXCEPTIONS, NO_FIELDS, NO_MEMBER_TYPES, NO_METHODS, NO_PARAMETERS, NO_SUPERINTERFACES, NO_TYPE_VARIABLES, NO_TYPES, PACKAGE, PARAMETERIZED_TYPE, RAW_TYPE, TYPE, TYPE_PARAMETER, UNINITIALIZED_FIELDS, UNINITIALIZED_METHODS, UNINITIALIZED_REFERENCE_TYPES, VARIABLE, WILDCARD_TYPE
 
Constructor Summary
TypeBinding()
           
 
Method Summary
 boolean canBeInstantiated()
           
 TypeBinding capture(Scope scope, int position)
          Perform capture conversion on a given type (only effective on parameterized type with wildcards)
 TypeBinding closestMatch()
          In case of problems, returns the closest match found.
 List collectMissingTypes(List missingTypes)
          Iterate through the type components to collect instances of leaf missing types
 void collectSubstitutes(Scope scope, TypeBinding actualType, InferenceContext inferenceContext, int constraint)
          Collect the substitutes into a map for certain type variables inside the receiver type e.g.
abstract  char[] constantPoolName()
          Answer the receiver's constant pool name.
 String debugName()
           
 int dimensions()
           
 ReferenceBinding enclosingType()
           
 TypeBinding erasure()
           
 ReferenceBinding findSuperTypeOriginatingFrom(int wellKnownOriginalID, boolean originalIsClass)
          Find supertype which originates from a given well-known type, or null if not found (using id avoids triggering the load of well-known type: 73740) NOTE: only works for erasures of well-known types, as random other types may share same id though being distincts.
 TypeBinding findSuperTypeOriginatingFrom(TypeBinding otherType)
          Find supertype which originates from a given type, or null if not found
 TypeBinding genericCast(TypeBinding targetType)
          Returns the type to use for generic cast, or null if none required
 char[] genericTypeSignature()
          Answer the receiver classfile signature.
 TypeBinding getErasureCompatibleType(TypeBinding declaringClass)
          Return the supertype which would erase as a subtype of a given declaring class.
abstract  PackageBinding getPackage()
           
 boolean isAnnotationType()
           
 boolean isAnonymousType()
           
 boolean isArrayType()
           
 boolean isBaseType()
           
 boolean isBoundParameterizedType()
          Returns true if parameterized type AND not of the form List
 boolean isCapture()
          Returns true if the type is the capture of some wildcard
 boolean isClass()
           
abstract  boolean isCompatibleWith(TypeBinding right)
           
 boolean isEnum()
           
 boolean isEquivalentTo(TypeBinding otherType)
          Returns true if a type is identical to another one, or for generic types, true if compared to its raw type.
 boolean isGenericType()
           
 boolean isHierarchyInconsistent()
           
 boolean isInterface()
           
 boolean isIntersectionType()
          Returns true if the current type denotes an intersection type: Number & Comparable
 boolean isLocalType()
           
 boolean isMemberType()
           
 boolean isNestedType()
           
 boolean isNumericType()
           
 boolean isParameterizedType()
          Returns true if the type is parameterized, e.g.
 boolean isParameterizedTypeWithActualArguments()
          Returns true if the type is parameterized, e.g.
 boolean isParameterizedWithOwnVariables()
          Returns true if the type is parameterized using its own type variables as arguments
 boolean isProvablyDistinct(TypeBinding otherType)
          Returns true if a type is provably distinct from another one,
 boolean isRawType()
           
 boolean isReifiable()
          JLS(3) 4.7.
 boolean isThrowable()
          Returns true if a given type may be thrown
 boolean isTypeArgumentContainedBy(TypeBinding otherType)
           
 boolean isTypeVariable()
          Returns true if the type was declared as a type variable
 boolean isUnboundWildcard()
          Returns true if wildcard type of the form '?' (no bound)
 boolean isUncheckedException(boolean includeSupertype)
          Returns true if the type is a subclass of java.lang.Error or java.lang.RuntimeException
 boolean isWildcard()
          Returns true if the type is a wildcard
 int kind()
           
 TypeBinding leafComponentType()
           
 boolean needsUncheckedConversion(TypeBinding targetType)
          Meant to be invoked on compatible types, to figure if unchecked conversion is necessary
 TypeBinding original()
          Returns the orignal generic type instantiated by the receiver type, or itself if not.
 char[] qualifiedPackageName()
          Answer the qualified name of the receiver's package separated by periods or an empty string if its the default package.
abstract  char[] qualifiedSourceName()
          Answer the source name for the type.
 char[] signature()
          Answer the receiver classfile signature.
abstract  char[] sourceName()
           
 void swapUnresolved(UnresolvedReferenceBinding unresolvedType, ReferenceBinding resolvedType, LookupEnvironment environment)
           
 TypeVariableBinding[] typeVariables()
           
static TypeBinding wellKnownType(Scope scope, int id)
          Match a well-known type id to its binding
 
Methods inherited from class org.eclipse.jdt.internal.compiler.lookup.Binding
computeUniqueKey, computeUniqueKey, getAnnotationTagBits, initializeDeprecatedAnnotationTagBits, isParameter, isValidBinding, isVolatile, problemId, readableName, shortReadableName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public int id

tagBits

public long tagBits

INT

public static final BaseTypeBinding INT
Base type definitions


BYTE

public static final BaseTypeBinding BYTE

SHORT

public static final BaseTypeBinding SHORT

CHAR

public static final BaseTypeBinding CHAR

LONG

public static final BaseTypeBinding LONG

FLOAT

public static final BaseTypeBinding FLOAT

DOUBLE

public static final BaseTypeBinding DOUBLE

BOOLEAN

public static final BaseTypeBinding BOOLEAN

NULL

public static final BaseTypeBinding NULL

VOID

public static final BaseTypeBinding VOID
Constructor Detail

TypeBinding

public TypeBinding()
Method Detail

wellKnownType

public static final TypeBinding wellKnownType(Scope scope,
                                              int id)
Match a well-known type id to its binding


canBeInstantiated

public boolean canBeInstantiated()

capture

public TypeBinding capture(Scope scope,
                           int position)
Perform capture conversion on a given type (only effective on parameterized type with wildcards)


closestMatch

public TypeBinding closestMatch()
In case of problems, returns the closest match found. It may not be perfect match, but the result of a best effort to improve fault-tolerance.


collectMissingTypes

public List collectMissingTypes(List missingTypes)
Iterate through the type components to collect instances of leaf missing types

Parameters:
missingTypes -
Returns:
missing types

collectSubstitutes

public void collectSubstitutes(Scope scope,
                               TypeBinding actualType,
                               InferenceContext inferenceContext,
                               int constraint)
Collect the substitutes into a map for certain type variables inside the receiver type e.g. Collection.findSubstitute(T, Collection>): T --> List Constraints: A << F corresponds to: F.collectSubstitutes(..., A, ..., CONSTRAINT_EXTENDS (1)) A = F corresponds to: F.collectSubstitutes(..., A, ..., CONSTRAINT_EQUAL (0)) A >> F corresponds to: F.collectSubstitutes(..., A, ..., CONSTRAINT_SUPER (2))


constantPoolName

public abstract char[] constantPoolName()
Answer the receiver's constant pool name. NOTE: This method should only be used during/after code gen. e.g. 'java/lang/Object'


debugName

public String debugName()

dimensions

public int dimensions()

enclosingType

public ReferenceBinding enclosingType()

erasure

public TypeBinding erasure()

findSuperTypeOriginatingFrom

public ReferenceBinding findSuperTypeOriginatingFrom(int wellKnownOriginalID,
                                                     boolean originalIsClass)
Find supertype which originates from a given well-known type, or null if not found (using id avoids triggering the load of well-known type: 73740) NOTE: only works for erasures of well-known types, as random other types may share same id though being distincts.

See Also:
TypeIds

findSuperTypeOriginatingFrom

public TypeBinding findSuperTypeOriginatingFrom(TypeBinding otherType)
Find supertype which originates from a given type, or null if not found


genericCast

public TypeBinding genericCast(TypeBinding targetType)
Returns the type to use for generic cast, or null if none required


genericTypeSignature

public char[] genericTypeSignature()
Answer the receiver classfile signature. Arrays & base types do not distinguish between signature() & constantPoolName(). NOTE: This method should only be used during/after code gen.


getErasureCompatibleType

public TypeBinding getErasureCompatibleType(TypeBinding declaringClass)
Return the supertype which would erase as a subtype of a given declaring class. If the receiver is already erasure compatible, then it will returned. If not, then will return the alternate lowest upper bound compatible with declaring class. NOTE: the declaringClass is already know to be compatible with the receiver

Parameters:
declaringClass - to look for
Returns:
the lowest erasure compatible type (considering alternate bounds)

getPackage

public abstract PackageBinding getPackage()

isAnnotationType

public boolean isAnnotationType()

isAnonymousType

public final boolean isAnonymousType()

isArrayType

public final boolean isArrayType()

isBaseType

public final boolean isBaseType()

isBoundParameterizedType

public boolean isBoundParameterizedType()
Returns true if parameterized type AND not of the form List


isCapture

public boolean isCapture()
Returns true if the type is the capture of some wildcard


isClass

public boolean isClass()

isCompatibleWith

public abstract boolean isCompatibleWith(TypeBinding right)

isEnum

public boolean isEnum()

isEquivalentTo

public boolean isEquivalentTo(TypeBinding otherType)
Returns true if a type is identical to another one, or for generic types, true if compared to its raw type.


isGenericType

public boolean isGenericType()

isHierarchyInconsistent

public final boolean isHierarchyInconsistent()

isInterface

public boolean isInterface()

isIntersectionType

public boolean isIntersectionType()
Returns true if the current type denotes an intersection type: Number & Comparable


isLocalType

public final boolean isLocalType()

isMemberType

public final boolean isMemberType()

isNestedType

public final boolean isNestedType()

isNumericType

public final boolean isNumericType()

isParameterizedType

public final boolean isParameterizedType()
Returns true if the type is parameterized, e.g. List. Note that some instances of ParameterizedTypeBinding have no arguments, like for non-generic members of a parameterized type. Use isParameterizedTypeWithActualArguments() instead to find out.


isParameterizedTypeWithActualArguments

public final boolean isParameterizedTypeWithActualArguments()
Returns true if the type is parameterized, e.g. List Note that some instances of ParameterizedTypeBinding do answer false to isParameterizedType() in case they have no arguments, like for non-generic members of a parameterized type. i.e. isParameterizedType() is not equivalent to testing type.kind() == Binding.PARAMETERIZED_TYPE


isParameterizedWithOwnVariables

public boolean isParameterizedWithOwnVariables()
Returns true if the type is parameterized using its own type variables as arguments


isProvablyDistinct

public boolean isProvablyDistinct(TypeBinding otherType)
Returns true if a type is provably distinct from another one,


isRawType

public final boolean isRawType()

isReifiable

public boolean isReifiable()
JLS(3) 4.7. Note: Foo.Bar is also reifiable


isThrowable

public boolean isThrowable()
Returns true if a given type may be thrown


isTypeArgumentContainedBy

public boolean isTypeArgumentContainedBy(TypeBinding otherType)

isTypeVariable

public boolean isTypeVariable()
Returns true if the type was declared as a type variable


isUnboundWildcard

public boolean isUnboundWildcard()
Returns true if wildcard type of the form '?' (no bound)


isUncheckedException

public boolean isUncheckedException(boolean includeSupertype)
Returns true if the type is a subclass of java.lang.Error or java.lang.RuntimeException


isWildcard

public boolean isWildcard()
Returns true if the type is a wildcard


kind

public int kind()
Specified by:
kind in class Binding

leafComponentType

public TypeBinding leafComponentType()

needsUncheckedConversion

public boolean needsUncheckedConversion(TypeBinding targetType)
Meant to be invoked on compatible types, to figure if unchecked conversion is necessary


original

public TypeBinding original()
Returns the orignal generic type instantiated by the receiver type, or itself if not. This is similar to erasure process, except it doesn't erase type variable, wildcard, intersection types etc...


qualifiedPackageName

public char[] qualifiedPackageName()
Answer the qualified name of the receiver's package separated by periods or an empty string if its the default package. For example, {java.util}.


qualifiedSourceName

public abstract char[] qualifiedSourceName()
Answer the source name for the type. In the case of member types, as the qualified name from its top level type. For example, for a member type N defined inside M & A: "A.M.N".


signature

public char[] signature()
Answer the receiver classfile signature. Arrays & base types do not distinguish between signature() & constantPoolName(). NOTE: This method should only be used during/after code gen.


sourceName

public abstract char[] sourceName()

swapUnresolved

public void swapUnresolved(UnresolvedReferenceBinding unresolvedType,
                           ReferenceBinding resolvedType,
                           LookupEnvironment environment)

typeVariables

public TypeVariableBinding[] typeVariables()


Copyright © 2012. All Rights Reserved.