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

java.lang.Object
  extended by org.eclipse.jdt.internal.compiler.lookup.Binding
      extended by org.eclipse.jdt.internal.compiler.lookup.TypeBinding
          extended by org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
All Implemented Interfaces:
IDependent
Direct Known Subclasses:
BinaryTypeBinding, ParameterizedTypeBinding, ProblemReferenceBinding, SourceTypeBinding, TypeVariableBinding, UnresolvedReferenceBinding, WildcardBinding

public abstract class ReferenceBinding
extends TypeBinding
implements IDependent


Field Summary
 char[][] compoundName
           
 PackageBinding fPackage
           
static ReferenceBinding LUB_GENERIC
           
 int modifiers
           
 char[] sourceName
           
 
Fields inherited from class org.eclipse.jdt.internal.compiler.lookup.TypeBinding
BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, id, INT, LONG, NULL, SHORT, tagBits, 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, VARIABLE, WILDCARD_TYPE
 
Fields inherited from interface org.eclipse.jdt.internal.compiler.env.IDependent
JAR_FILE_ENTRY_SEPARATOR
 
Constructor Summary
ReferenceBinding()
           
 
Method Summary
 FieldBinding[] availableFields()
          Return the array of resolvable fields (resilience)
 MethodBinding[] availableMethods()
          Return the array of resolvable methods (resilience)
static FieldBinding binarySearch(char[] name, FieldBinding[] sortedFields)
           
static long binarySearch(char[] selector, MethodBinding[] sortedMethods)
          Returns a combined range value representing: (start + (end<<32)), where start is the index of the first matching method (remember methods are sorted alphabetically on selectors), and end is the index of last contiguous methods with same selector.
 boolean canBeInstantiated()
          Answer true if the receiver can be instantiated
 boolean canBeSeenBy(PackageBinding invocationPackage)
          Answer true if the receiver is visible to the invocationPackage.
 boolean canBeSeenBy(ReferenceBinding receiverType, ReferenceBinding invocationType)
          Answer true if the receiver is visible to the receiverType and the invocationType.
 boolean canBeSeenBy(Scope scope)
          Answer true if the receiver is visible to the type provided by the scope.
 char[] computeGenericTypeSignature(TypeVariableBinding[] typeVariables)
           
 void computeId()
           
 char[] computeUniqueKey(boolean isLeaf)
          p.X {} -> Lp/X;
 char[] constantPoolName()
          Answer the receiver's constant pool name.
 java.lang.String debugName()
           
 int depth()
           
 boolean detectAnnotationCycle()
           
 ReferenceBinding enclosingTypeAt(int relativeDepth)
           
 int enumConstantCount()
           
 int fieldCount()
           
 FieldBinding[] fields()
           
 int getAccessFlags()
           
 AnnotationBinding[] getAnnotations()
           
 long getAnnotationTagBits()
          Compute the tagbits for standard annotations.
 MethodBinding getExactConstructor(TypeBinding[] argumentTypes)
           
 MethodBinding getExactMethod(char[] selector, TypeBinding[] argumentTypes, CompilationUnitScope refScope)
           
 FieldBinding getField(char[] fieldName, boolean needResolve)
           
 char[] getFileName()
          Answer the file name which defines the type.
 ReferenceBinding getMemberType(char[] typeName)
           
 MethodBinding[] getMethods(char[] selector)
           
 PackageBinding getPackage()
           
 TypeVariableBinding getTypeVariable(char[] variableName)
           
 int hashCode()
           
 boolean hasIncompatibleSuperType(ReferenceBinding otherType)
          Returns true if the two types have an incompatible common supertype, e.g.
 boolean hasMemberTypes()
           
 boolean hasRestrictedAccess()
           
 boolean implementsInterface(ReferenceBinding anInterface, boolean searchHierarchy)
          Answer true if the receiver implements anInterface or is identical to anInterface.
 boolean isAbstract()
          Answer true if the receiver is an abstract type
 boolean isAnnotationType()
           
 boolean isBinaryBinding()
           
 boolean isClass()
           
 boolean isCompatibleWith(TypeBinding otherType)
          Answer true if the receiver type can be assigned to the argument type (right) In addition to improving performance, caching also ensures there is no infinite regression since per nature, the compatibility check is recursive through parameterized type arguments (122775)
 boolean isDefault()
          Answer true if the receiver has default visibility
 boolean isDeprecated()
          Answer true if the receiver is a deprecated type
 boolean isEnum()
           
 boolean isFinal()
          Answer true if the receiver is final and cannot be subclassed
 boolean isHierarchyBeingConnected()
          Returns true if the type hierarchy is being connected
 boolean isInterface()
           
 boolean isPrivate()
          Answer true if the receiver has private visibility
 boolean isProtected()
          Answer true if the receiver has protected visibility
 boolean isPublic()
          Answer true if the receiver has public visibility
 boolean isStatic()
          Answer true if the receiver is a static member type (or toplevel)
 boolean isStrictfp()
          Answer true if all float operations must adher to IEEE 754 float/double rules
 boolean isSuperclassOf(ReferenceBinding otherType)
          Answer true if the receiver is in the superclass hierarchy of aType NOTE: Object.isSuperclassOf(Object) -> false
 boolean isThrowable()
          Returns true if a given type may be thrown
 boolean isUncheckedException(boolean includeSupertype)
          JLS 11.5 ensures that Throwable, Exception, RuntimeException and Error are directly connected.
 boolean isUsed()
          Answer true if the receiver has private visibility and is used locally
 boolean isViewedAsDeprecated()
          Answer true if the receiver is deprecated (or any of its enclosing types)
 ReferenceBinding[] memberTypes()
           
 MethodBinding[] methods()
           
 ReferenceBinding outermostEnclosingType()
           
 char[] qualifiedSourceName()
          Answer the source name for the type.
 char[] readableName()
          Answer the receiver's signature.
 AnnotationHolder retrieveAnnotationHolder(Binding binding, boolean forceInitialization)
           
 void setAnnotations(AnnotationBinding[] annotations)
           
 char[] shortReadableName()
           
 char[] signature()
          Answer the receiver classfile signature.
static void sortFields(FieldBinding[] sortedFields, int left, int right)
          Sort the field array using a quicksort
static void sortMethods(MethodBinding[] sortedMethods, int left, int right)
          Sort the field array using a quicksort
 char[] sourceName()
           
 ReferenceBinding superclass()
           
 ReferenceBinding[] superInterfaces()
           
 ReferenceBinding[] syntheticEnclosingInstanceTypes()
           
 SyntheticArgumentBinding[] syntheticOuterLocalVariables()
           
 
Methods inherited from class org.eclipse.jdt.internal.compiler.lookup.TypeBinding
capture, closestMatch, collectMissingTypes, collectSubstitutes, dimensions, enclosingType, erasure, findSuperTypeOriginatingFrom, findSuperTypeOriginatingFrom, genericCast, genericTypeSignature, isAnonymousType, isArrayType, isBaseType, isBoundParameterizedType, isCapture, isEquivalentTo, isGenericType, isHierarchyInconsistent, isIntersectionType, isLocalType, isMemberType, isNestedType, isNumericType, isParameterizedType, isParameterizedWithOwnVariables, isProvablyDistinct, isRawType, isReifiable, isTypeArgumentContainedBy, isTypeVariable, isUnboundWildcard, isWildcard, kind, leafComponentType, needsUncheckedConversion, original, qualifiedPackageName, swapUnresolved, typeVariables, wellKnownType
 
Methods inherited from class org.eclipse.jdt.internal.compiler.lookup.Binding
computeUniqueKey, initializeDeprecatedAnnotationTagBits, isValidBinding, problemId
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compoundName

public char[][] compoundName

sourceName

public char[] sourceName

modifiers

public int modifiers

fPackage

public PackageBinding fPackage

LUB_GENERIC

public static ReferenceBinding LUB_GENERIC
Constructor Detail

ReferenceBinding

public ReferenceBinding()
Method Detail

binarySearch

public static FieldBinding binarySearch(char[] name,
                                        FieldBinding[] sortedFields)

binarySearch

public static long binarySearch(char[] selector,
                                MethodBinding[] sortedMethods)
Returns a combined range value representing: (start + (end<<32)), where start is the index of the first matching method (remember methods are sorted alphabetically on selectors), and end is the index of last contiguous methods with same selector. -1 means no method got found

Parameters:
selector -
sortedMethods -
Returns:
(start + (end<<32)) or -1 if no method found

sortFields

public static void sortFields(FieldBinding[] sortedFields,
                              int left,
                              int right)
Sort the field array using a quicksort


sortMethods

public static void sortMethods(MethodBinding[] sortedMethods,
                               int left,
                               int right)
Sort the field array using a quicksort


availableFields

public FieldBinding[] availableFields()
Return the array of resolvable fields (resilience)


availableMethods

public MethodBinding[] availableMethods()
Return the array of resolvable methods (resilience)


canBeInstantiated

public boolean canBeInstantiated()
Answer true if the receiver can be instantiated

Overrides:
canBeInstantiated in class TypeBinding

canBeSeenBy

public final boolean canBeSeenBy(PackageBinding invocationPackage)
Answer true if the receiver is visible to the invocationPackage.


canBeSeenBy

public final boolean canBeSeenBy(ReferenceBinding receiverType,
                                 ReferenceBinding invocationType)
Answer true if the receiver is visible to the receiverType and the invocationType.


canBeSeenBy

public final boolean canBeSeenBy(Scope scope)
Answer true if the receiver is visible to the type provided by the scope.


computeGenericTypeSignature

public char[] computeGenericTypeSignature(TypeVariableBinding[] typeVariables)

computeId

public void computeId()

computeUniqueKey

public char[] computeUniqueKey(boolean isLeaf)
p.X {} -> Lp/X;

Overrides:
computeUniqueKey in class Binding

constantPoolName

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

Specified by:
constantPoolName in class TypeBinding

debugName

public java.lang.String debugName()
Overrides:
debugName in class TypeBinding

depth

public final int depth()

detectAnnotationCycle

public boolean detectAnnotationCycle()

enclosingTypeAt

public final ReferenceBinding enclosingTypeAt(int relativeDepth)

enumConstantCount

public int enumConstantCount()

fieldCount

public int fieldCount()

fields

public FieldBinding[] fields()

getAccessFlags

public final int getAccessFlags()

getAnnotations

public AnnotationBinding[] getAnnotations()
Returns:
the JSR 175 annotations for this type.

getAnnotationTagBits

public long getAnnotationTagBits()
Description copied from class: Binding
Compute the tagbits for standard annotations. For source types, these could require lazily resolving corresponding annotation nodes, in case of forward references.

Overrides:
getAnnotationTagBits in class Binding
See Also:
Binding.getAnnotationTagBits()

getExactConstructor

public MethodBinding getExactConstructor(TypeBinding[] argumentTypes)

getExactMethod

public MethodBinding getExactMethod(char[] selector,
                                    TypeBinding[] argumentTypes,
                                    CompilationUnitScope refScope)

getField

public FieldBinding getField(char[] fieldName,
                             boolean needResolve)

getFileName

public char[] getFileName()
Description copied from interface: IDependent
Answer the file name which defines the type. The path part (optional) must be separated from the actual file proper name by a separator suitable for the type (java.io.File.separator for example), e.g. "c:\\source\\com\\p\\X.java" or "/com/p/Y.java". The path to the zip or jar file (optional) must be separated from the actual path part by JAR_FILE_ENTRY_SEPARATOR, e.g. "c:\\lib\\some.jar|/com/p/X.class" or "/lib/some.zip|/com/q/Y.class". The proper file name includes the suffix extension (e.g. ".java") e.g. "c:/org/eclipse/jdt/internal/compileri/env/IDependent.java" Return null if no file defines the type.

Specified by:
getFileName in interface IDependent
See Also:
IDependent.getFileName()

getMemberType

public ReferenceBinding getMemberType(char[] typeName)

getMethods

public MethodBinding[] getMethods(char[] selector)

getPackage

public PackageBinding getPackage()
Specified by:
getPackage in class TypeBinding

getTypeVariable

public TypeVariableBinding getTypeVariable(char[] variableName)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

hasIncompatibleSuperType

public boolean hasIncompatibleSuperType(ReferenceBinding otherType)
Returns true if the two types have an incompatible common supertype, e.g. List and List


hasMemberTypes

public boolean hasMemberTypes()

hasRestrictedAccess

public final boolean hasRestrictedAccess()

implementsInterface

public boolean implementsInterface(ReferenceBinding anInterface,
                                   boolean searchHierarchy)
Answer true if the receiver implements anInterface or is identical to anInterface. If searchHierarchy is true, then also search the receiver's superclasses. NOTE: Assume that anInterface is an interface.


isAbstract

public final boolean isAbstract()
Answer true if the receiver is an abstract type


isAnnotationType

public boolean isAnnotationType()
Overrides:
isAnnotationType in class TypeBinding

isBinaryBinding

public final boolean isBinaryBinding()

isClass

public boolean isClass()
Overrides:
isClass in class TypeBinding

isCompatibleWith

public boolean isCompatibleWith(TypeBinding otherType)
Answer true if the receiver type can be assigned to the argument type (right) In addition to improving performance, caching also ensures there is no infinite regression since per nature, the compatibility check is recursive through parameterized type arguments (122775)

Specified by:
isCompatibleWith in class TypeBinding

isDefault

public final boolean isDefault()
Answer true if the receiver has default visibility


isDeprecated

public final boolean isDeprecated()
Answer true if the receiver is a deprecated type


isEnum

public boolean isEnum()
Overrides:
isEnum in class TypeBinding

isFinal

public final boolean isFinal()
Answer true if the receiver is final and cannot be subclassed


isHierarchyBeingConnected

public boolean isHierarchyBeingConnected()
Returns true if the type hierarchy is being connected


isInterface

public boolean isInterface()
Overrides:
isInterface in class TypeBinding

isPrivate

public final boolean isPrivate()
Answer true if the receiver has private visibility


isProtected

public final boolean isProtected()
Answer true if the receiver has protected visibility


isPublic

public final boolean isPublic()
Answer true if the receiver has public visibility


isStatic

public final boolean isStatic()
Answer true if the receiver is a static member type (or toplevel)


isStrictfp

public final boolean isStrictfp()
Answer true if all float operations must adher to IEEE 754 float/double rules


isSuperclassOf

public boolean isSuperclassOf(ReferenceBinding otherType)
Answer true if the receiver is in the superclass hierarchy of aType NOTE: Object.isSuperclassOf(Object) -> false


isThrowable

public boolean isThrowable()
Description copied from class: TypeBinding
Returns true if a given type may be thrown

Overrides:
isThrowable in class TypeBinding
See Also:
TypeBinding.isThrowable()

isUncheckedException

public boolean isUncheckedException(boolean includeSupertype)
JLS 11.5 ensures that Throwable, Exception, RuntimeException and Error are directly connected. (Throwable<- Exception <- RumtimeException, Throwable <- Error). Thus no need to check #isCompatibleWith but rather check in type IDs so as to avoid some eager class loading for JCL writers. When 'includeSupertype' is true, answers true if the given type can be a supertype of some unchecked exception type (i.e. Throwable or Exception).

Overrides:
isUncheckedException in class TypeBinding
See Also:
TypeBinding.isUncheckedException(boolean)

isUsed

public final boolean isUsed()
Answer true if the receiver has private visibility and is used locally


isViewedAsDeprecated

public final boolean isViewedAsDeprecated()
Answer true if the receiver is deprecated (or any of its enclosing types)


memberTypes

public ReferenceBinding[] memberTypes()

methods

public MethodBinding[] methods()

outermostEnclosingType

public final ReferenceBinding outermostEnclosingType()

qualifiedSourceName

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

Specified by:
qualifiedSourceName in class TypeBinding

readableName

public char[] readableName()
Answer the receiver's signature. NOTE: This method should only be used during/after code gen.

Specified by:
readableName in class Binding

retrieveAnnotationHolder

public AnnotationHolder retrieveAnnotationHolder(Binding binding,
                                                 boolean forceInitialization)

setAnnotations

public void setAnnotations(AnnotationBinding[] annotations)

shortReadableName

public char[] shortReadableName()
Overrides:
shortReadableName in class Binding

signature

public char[] signature()
Description copied from class: TypeBinding
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.

Overrides:
signature in class TypeBinding

sourceName

public char[] sourceName()
Specified by:
sourceName in class TypeBinding

superclass

public ReferenceBinding superclass()

superInterfaces

public ReferenceBinding[] superInterfaces()

syntheticEnclosingInstanceTypes

public ReferenceBinding[] syntheticEnclosingInstanceTypes()

syntheticOuterLocalVariables

public SyntheticArgumentBinding[] syntheticOuterLocalVariables()