Class TypeBinding
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding
- Direct Known Subclasses:
ArrayBinding,BaseTypeBinding,PolyTypeBinding,ReferenceBinding
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BaseTypeBindingstatic final BaseTypeBindingstatic final BaseTypeBindingstatic final BaseTypeBindingintstatic final BaseTypeBindingintstatic final BaseTypeBindingBase type definitionsstatic final BaseTypeBindingstatic final NullTypeBindingstatic final BaseTypeBindinglongstatic final ReferenceBindingprotected AnnotationBinding[]static final VoidTypeBindingFields inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding
ANY_EXCEPTION, ARRAY_TYPE, BASE_TYPE, DefaultLocationArrayContents, DefaultLocationField, DefaultLocationParameter, DefaultLocationReturnType, DefaultLocationsForTrueValue, DefaultLocationTypeArgument, DefaultLocationTypeBound, DefaultLocationTypeParameter, FIELD, GENERIC_TYPE, IMPORT, INTERSECTION_TYPE, INTERSECTION_TYPE18, LOCAL, METHOD, MODULE, NO_ANNOTATIONS, NO_COMPONENTS, NO_ELEMENT_VALUE_PAIRS, NO_EXCEPTIONS, NO_FIELDS, NO_MEMBER_TYPES, NO_METHODS, NO_MODULES, NO_NULL_DEFAULT, NO_PACKAGES, NO_PARAMETER_NAMES, NO_PARAMETERS, NO_PERMITTEDTYPES, NO_PLAIN_PACKAGES, NO_REFERENCE_TYPES, NO_SUPERINTERFACES, NO_TYPE_VARIABLES, NO_TYPES, NULL_UNSPECIFIED_BY_DEFAULT, NullnessDefaultMASK, PACKAGE, PARAMETERIZED_TYPE, PATTERN, POLY_TYPE, RAW_TYPE, RECORD_COMPONENT, TYPE, TYPE_PARAMETER, TYPE_USE, UNINITIALIZED_COMPONENTS, UNINITIALIZED_FIELDS, UNINITIALIZED_METHODS, UNINITIALIZED_REFERENCE_TYPES, VARIABLE, WILDCARD_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanUsed to implement this sentence from o.e.j.annotation.DefaultLocation: "Wildcards and the use of type variables are always excluded from NonNullByDefault."booleanbooleancanBeSeenBy(Scope scope) Perform capture conversion on a given type (only effective on parameterized type with wildcards)clone(TypeBinding enclosingType) Virtual copy constructor: a copy is made of the receiver's entire instance state and then suitably parameterized by the arguments to the clone operation as seen fit by each type.In case of problems, returns the closest match found.collectMissingTypes(List<TypeBinding> missingTypes) Iterate through the type components to collect instances of leaf missing typesvoidcollectSubstitutes(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[]Answer the receiver's constant pool name.intdepth()intdownwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) Perform a downwards type projection as per JLS 4.10.5booleanCall this before descending into type details to prevent infinite recursion.static booleanequalsEquals(TypeBinding that, TypeBinding other) erasure()voidExit the context of a potentially recursive function.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.findSuperTypeOriginatingFrom(TypeBinding otherType) Find supertype which originates from a given type, or null if not foundgenericCast(TypeBinding targetType) Returns the type to use for generic cast, or null if none requiredchar[]Answer the receiver classfile signature.getErasureCompatibleType(TypeBinding declaringClass) Return the supertype which would erase as a subtype of a given declaring class.getMethods(char[] selector) abstract PackageBindinggetSingleAbstractMethod(Scope scope, boolean replaceWildcards) Return the single abstract method of a functional interface, or one ofnullorReferenceBinding.samProblemBinding, if the receiver is not a functional interface as defined in JLS 9.8.final AnnotationBinding[]booleanDoes this type or any of its details (array dimensions, type arguments) have a null type annotation?final booleanbooleanhasTypeBit(int bit) Answer an additional bit characterizing this type, likeTypeIds.BitAutoCloseable.booleanfinal booleanfinal booleanfinal booleanbooleanReturns true if parameterized type AND not of the formList<?>booleanbooleanisBoxingCompatibleWith(TypeBinding right, Scope scope) booleanReturns true if the type is the capture of some wildcardbooleanisClass()booleanisCompatibleWith(TypeBinding right) abstract booleanisCompatibleWith(TypeBinding right, Scope scope) booleanisEnum()booleanisEquivalentTo(TypeBinding otherType) Returns true if a type is identical to another one, or for generic types, true if compared to its raw type.booleanbooleanisFunctionalInterface(Scope scope) booleanbooleanfinal booleanbooleanbooleanReturns true if the current type denotes an intersection type: Number andComparable<?>booleanfinal booleanfinal booleanfinal booleanbooleanDoes this type lack a class file representation on its own ?final booleanbooleanReturns true if the type is parameterized, e.g.final booleanReturns true if the type is parameterized, e.g.booleanReturns true if the type is parameterized using its own type variables as argumentsbooleanbooleanisPotentiallyCompatibleWith(TypeBinding right, Scope scope) final booleanfinal booleanbooleanisProperType(boolean admitCapture18) JLS8 Sect 18.1.1booleanisProvablyDistinct(TypeBinding otherType) Returns true if a type is provably distinct from another one,final booleanbooleanbooleanisRecord()booleanJLS(3) 4.7.booleanAnswer true if the receiver is an annotation which may be repeatable.booleanisStatic()Answer true if the receiver is a static member type (or toplevel)booleanisSubtypeOf(TypeBinding right, boolean simulatingBugJDK8026527) booleanReturns true if a given type may be thrownbooleanisTypeArgumentContainedBy(TypeBinding otherType) booleanReturns true if the type was declared as a type variablebooleanReturns true if wildcard type of the form '?' (no bound)booleanisUncheckedException(boolean includeSupertype) Returns true if the type is a subclass of java.lang.Error or java.lang.RuntimeExceptionbooleanbooleanReturns true if the type is a wildcardintkind()booleanmentionsAny(TypeBinding[] parameters, int idx) Does this type mention any of the given type parameters, except the one at position 'idx'?booleanneedsUncheckedConversion(TypeBinding targetType) Meant to be invoked on compatible types, to figure if unchecked conversion is necessarystatic booleannotEquals(TypeBinding that, TypeBinding other) char[]nullAnnotatedReadableName(CompilerOptions options, boolean shortNames) Answer a readable name (for error reporting) that includes nullness type annotations.original()Returns the orignal generic type instantiated by the receiver type, or itself if not.Return the primordial type from which the receiver was cloned.char[]Answer the qualified name of the receiver's package separated by periods or an empty string if its the default package.abstract char[]Answer the source name for the type.voidsetTypeAnnotations(AnnotationBinding[] annotations, boolean evalNullAnnotations) char[]char[]Answer the receiver classfile signature.booleansIsMoreSpecific(TypeBinding s, TypeBinding t, Scope scope) abstract char[]voidswapUnresolved(UnresolvedReferenceBinding unresolvedType, ReferenceBinding resolvedType, LookupEnvironment environment) Return this type minus its type annotationsPerform capture "deconversion" on a given typelongRefresh some tagBits from details into the main type.upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) Perform an upwards type projection as per JLS 4.10.5static final TypeBindingwellKnownBaseType(int id) static final TypeBindingwellKnownType(Scope scope, int id) Match a well-known type id to its bindingReturn this type minus its toplevel null annotations.Methods inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding
computeUniqueKey, computeUniqueKey, getAnnotations, getAnnotationTagBits, initializeDeprecatedAnnotationTagBits, isAnnotationType, isParameter, isPatternVariable, isTaggedRepeatable, isValid, isValidBinding, isVolatile, problemId, readableName, setAnnotations, setAnnotations, shortReadableName
-
Field Details
-
id
public int id -
tagBits
public long tagBits -
extendedTagBits
public int extendedTagBits -
typeAnnotations
-
TYPE_USE_BINDING
-
INT
Base type definitions -
BYTE
-
SHORT
-
CHAR
-
LONG
-
FLOAT
-
DOUBLE
-
BOOLEAN
-
NULL
-
VOID
-
-
Constructor Details
-
TypeBinding
public TypeBinding() -
TypeBinding
-
-
Method Details
-
wellKnownType
Match a well-known type id to its binding -
wellKnownBaseType
-
actualType
-
annotatedDebugName
-
containerAnnotationType
-
canBeInstantiated
public boolean canBeInstantiated() -
capture
Perform capture conversion on a given type (only effective on parameterized type with wildcards) -
uncapture
Perform capture "deconversion" on a given type -
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
Iterate through the type components to collect instances of leaf missing types- 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<T>.findSubstitute(T, Collection<List<X>>): T --> List<X> 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)) -
clone
Virtual copy constructor: a copy is made of the receiver's entire instance state and then suitably parameterized by the arguments to the clone operation as seen fit by each type. Parameters may not make sense for every type in the hierarchy, in which case they are silently ignored. A type may choose to retain a copy of the prototype for reference. -
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
-
dimensions
public int dimensions() -
depth
public int depth() -
enclosingMethod
-
enclosingType
-
erasure
-
upwardsProjection
Perform an upwards type projection as per JLS 4.10.5- Parameters:
scope- Relevant scope for evaluating type projectionmentionedTypeVariables- Filter for mentioned type variabled- Returns:
- Upwards type projection of 'this', or null if downwards projection is undefined
-
downwardsProjection
Perform a downwards type projection as per JLS 4.10.5- Parameters:
scope- Relevant scope for evaluating type projectionmentionedTypeVariables- Filter for mentioned type variabled- Returns:
- Downwards type projection of 'this', or null if downwards projection is undefined
-
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:
-
findSuperTypeOriginatingFrom
Find supertype which originates from a given type, or null if not found -
syntheticTypeVariablesMentioned
-
genericCast
Returns the type to use for generic cast, or null if none required -
genericTypeSignature
public char[] genericTypeSignature()Answer the receiver classfile signature. Arrays and base types do not distinguish between signature() and constantPoolName(). NOTE: This method should only be used during/after code gen. -
getErasureCompatibleType
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
-
isAnonymousType
public final boolean isAnonymousType() -
isArrayType
public final boolean isArrayType() -
isBaseType
public final boolean isBaseType() -
isPrimitiveType
public final boolean isPrimitiveType() -
isPrimitiveOrBoxedPrimitiveType
public final boolean isPrimitiveOrBoxedPrimitiveType() -
isBoxedPrimitiveType
public boolean isBoxedPrimitiveType() -
isBoundParameterizedType
public boolean isBoundParameterizedType()Returns true if parameterized type AND not of the formList<?> -
isCapture
public boolean isCapture()Returns true if the type is the capture of some wildcard -
isClass
public boolean isClass() -
isRecord
public boolean isRecord() -
isCompatibleWith
-
isCompatibleWith
-
isPotentiallyCompatibleWith
-
isBoxingCompatibleWith
-
isEnum
public boolean isEnum() -
isEquivalentTo
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() -
isFunctionalInterface
-
isIntersectionType
public boolean isIntersectionType()Returns true if the current type denotes an intersection type: Number andComparable<?> -
isLocalType
public final boolean isLocalType() -
isMemberType
public final boolean isMemberType() -
isNestedType
public final boolean isNestedType() -
isNumericType
public final boolean isNumericType() -
isParameterizedType
public boolean isParameterizedType()Returns true if the type is parameterized, e.g.List<String>. Note that some instances of ParameterizedTypeBinding have no arguments, like for non-generic members of a parameterized type. UseisParameterizedTypeWithActualArguments()instead to find out. -
hasNullTypeAnnotations
public boolean hasNullTypeAnnotations()Does this type or any of its details (array dimensions, type arguments) have a null type annotation? -
acceptsNonNullDefault
public boolean acceptsNonNullDefault()Used to implement this sentence from o.e.j.annotation.DefaultLocation: "Wildcards and the use of type variables are always excluded from NonNullByDefault." -
isIntersectionType18
public boolean isIntersectionType18() -
isParameterizedTypeWithActualArguments
public final boolean isParameterizedTypeWithActualArguments()Returns true if the type is parameterized, e.g.List<String>. Note that some instances of ParameterizedTypeBinding do answer false toisParameterizedType()in case they have no arguments, like for non-generic members of a parameterized type. i.e.isParameterizedType()is not equivalent to testingtype.kind() == Binding.PARAMETERIZED_TYPE -
isParameterizedWithOwnVariables
public boolean isParameterizedWithOwnVariables()Returns true if the type is parameterized using its own type variables as arguments -
isProperType
public boolean isProperType(boolean admitCapture18) JLS8 Sect 18.1.1- Parameters:
admitCapture18- request ifCaptureBinding18shuld be considered as a proper type. If unsure say 'true', only inScope.greaterLowerBound(TypeBinding[], Scope, LookupEnvironment)CaptureBinding18 has to be excluded to prevent an NPE on a branch that heuristically tries to avoid inconsistent intersections.
-
isPolyType
public boolean isPolyType() -
isProvablyDistinct
Returns true if a type is provably distinct from another one, -
isReadyForAnnotations
public boolean isReadyForAnnotations() -
isRepeatableAnnotationType
public boolean isRepeatableAnnotationType()Answer true if the receiver is an annotation which may be repeatable. Overridden as appropriate. -
isRawType
public final boolean isRawType() -
isReifiable
public boolean isReifiable()JLS(3) 4.7. Note:Foo<?>.Baris also reifiable -
isStatic
public boolean isStatic()Answer true if the receiver is a static member type (or toplevel) -
isThrowable
public boolean isThrowable()Returns true if a given type may be thrown -
isTypeArgumentContainedBy
-
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
-
leafComponentType
-
needsUncheckedConversion
Meant to be invoked on compatible types, to figure if unchecked conversion is necessary -
nullAnnotatedReadableName
Answer a readable name (for error reporting) that includes nullness type annotations. -
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... -
unannotated
Return this type minus its type annotations -
withoutToplevelNullAnnotation
Return this type minus its toplevel null annotations. Any annotations on type arguments or bounds are retained. -
hasTypeAnnotations
public final boolean hasTypeAnnotations() -
hasValueBasedTypeAnnotation
public boolean hasValueBasedTypeAnnotation() -
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 insideM & A: "A.M.N". -
getTypeAnnotations
- Returns:
- the JSR 308 annotations for this type.
-
setTypeAnnotations
-
signableName
public char[] signableName() -
signature
public char[] signature()Answer the receiver classfile signature. Arrays and base types do not distinguish between signature() and 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
-
getSingleAbstractMethod
Return the single abstract method of a functional interface, or one ofnullorReferenceBinding.samProblemBinding, if the receiver is not a functional interface as defined in JLS 9.8. In particularnullis answered if the receiver is not a reference type, or is a problem type.- Parameters:
scope- scopereplaceWildcards- Should wildcards be replaced following JLS 9.8? Say false for lambdas with explicit argument types which should apply 18.5.3- Returns:
- The single abstract method of a functional interface, or one of
nullorReferenceBinding.samProblemBinding, if the receiver is not a functional interface.
-
getIntersectingTypes
-
equalsEquals
-
notEquals
-
prototype
Return the primordial type from which the receiver was cloned. Not all types track a prototype, onlySourceTypeBinding,BinaryTypeBindingandUnresolvedReferenceBindingdo so as of now. In fact some types e.gParameterizedTypeBindingshould not do so. Deflecting a query to a prototype would lead to wrong results in the case ofParameterizedTypeBinding -
isUnresolvedType
public boolean isUnresolvedType() -
mentionsAny
Does this type mention any of the given type parameters, except the one at position 'idx'? -
hasTypeBit
public boolean hasTypeBit(int bit) Answer an additional bit characterizing this type, likeTypeIds.BitAutoCloseable. -
sIsMoreSpecific
-
isSubtypeOf
-
getMethods
-
canBeSeenBy
-
superclass
-
permittedTypes
-
superInterfaces
-
components
-
syntheticOuterLocalVariables
-
enterRecursiveFunction
public boolean enterRecursiveFunction()Call this before descending into type details to prevent infinite recursion.- Returns:
- true if a recursion was not already started.
-
exitRecursiveFunction
public void exitRecursiveFunction()Exit the context of a potentially recursive function. -
isFunctionalType
public boolean isFunctionalType() -
updateTagBits
public long updateTagBits()Refresh some tagBits from details into the main type. Currently handled: TagBits.HasNullTypeAnnotation -
isFreeTypeVariable
public boolean isFreeTypeVariable() -
isNonDenotable
public boolean isNonDenotable()Does this type lack a class file representation on its own ?
-