public abstract class TypeBinding extends Binding
| Modifier and Type | Field and Description |
|---|---|
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 NullTypeBinding |
NULL |
static BaseTypeBinding |
SHORT |
long |
tagBits |
static ReferenceBinding |
TYPE_USE_BINDING |
protected AnnotationBinding[] |
typeAnnotations |
static VoidTypeBinding |
VOID |
ANY_EXCEPTION, ARRAY_TYPE, BASE_TYPE, DefaultLocationArrayContents, DefaultLocationField, DefaultLocationParameter, DefaultLocationReturnType, DefaultLocationTypeArgument, DefaultLocationTypeBound, DefaultLocationTypeParameter, FIELD, GENERIC_TYPE, IMPORT, INTERSECTION_TYPE, INTERSECTION_TYPE18, LOCAL, METHOD, NO_ANNOTATIONS, NO_ELEMENT_VALUE_PAIRS, NO_EXCEPTIONS, NO_FIELDS, NO_MEMBER_TYPES, NO_METHODS, NO_NULL_DEFAULT, NO_PARAMETER_NAMES, NO_PARAMETERS, NO_REFERENCE_TYPES, NO_SUPERINTERFACES, NO_TYPE_VARIABLES, NO_TYPES, NONNULL_BY_DEFAULT, NULL_UNSPECIFIED_BY_DEFAULT, NullnessDefaultMASK, PACKAGE, PARAMETERIZED_TYPE, POLY_TYPE, RAW_TYPE, TYPE, TYPE_PARAMETER, TYPE_USE, UNINITIALIZED_FIELDS, UNINITIALIZED_METHODS, UNINITIALIZED_REFERENCE_TYPES, VARIABLE, WILDCARD_TYPE| Constructor and Description |
|---|
TypeBinding() |
TypeBinding(TypeBinding prototype) |
| Modifier and Type | Method and Description |
|---|---|
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."
|
ReferenceBinding |
actualType() |
java.lang.String |
annotatedDebugName() |
boolean |
canBeInstantiated() |
boolean |
canBeSeenBy(Scope scope) |
TypeBinding |
capture(Scope scope,
int start,
int end)
Perform capture conversion on a given type (only effective on parameterized type with wildcards)
|
TypeBinding |
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.
|
TypeBinding |
closestMatch()
In case of problems, returns the closest match found.
|
java.util.List<TypeBinding> |
collectMissingTypes(java.util.List<TypeBinding> 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.
|
ReferenceBinding |
containerAnnotationType() |
java.lang.String |
debugName() |
int |
depth() |
int |
dimensions() |
MethodBinding |
enclosingMethod() |
ReferenceBinding |
enclosingType() |
boolean |
enterRecursiveFunction()
Call this before descending into type details to prevent infinite recursion.
|
static boolean |
equalsEquals(TypeBinding that,
TypeBinding other) |
TypeBinding |
erasure() |
void |
exitRecursiveFunction()
Exit the context of a potentially recursive function.
|
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.
|
ReferenceBinding[] |
getIntersectingTypes() |
MethodBinding[] |
getMethods(char[] selector) |
abstract PackageBinding |
getPackage() |
MethodBinding |
getSingleAbstractMethod(Scope scope,
boolean replaceWildcards)
Return the single abstract method of a functional interface, or one of
null or ReferenceBinding.samProblemBinding, if the receiver is not a functional interface as defined in JLS 9.8. |
AnnotationBinding[] |
getTypeAnnotations() |
boolean |
hasNullTypeAnnotations()
Does this type or any of its details (array dimensions, type arguments)
have a null type annotation?
|
boolean |
hasTypeAnnotations() |
boolean |
hasTypeBit(int bit)
Answer an additional bit characterizing this type, like
TypeIds.BitAutoCloseable. |
boolean |
isAnonymousType() |
boolean |
isArrayType() |
boolean |
isBaseType() |
boolean |
isBoundParameterizedType()
Returns true if parameterized type AND not of the form List>
|
boolean |
isBoxedPrimitiveType() |
boolean |
isBoxingCompatibleWith(TypeBinding right,
Scope scope) |
boolean |
isCapture()
Returns true if the type is the capture of some wildcard
|
boolean |
isClass() |
boolean |
isCompatibleWith(TypeBinding right) |
abstract boolean |
isCompatibleWith(TypeBinding right,
Scope scope) |
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 |
isFreeTypeVariable() |
boolean |
isFunctionalInterface(Scope scope) |
boolean |
isFunctionalType() |
boolean |
isGenericType() |
boolean |
isHierarchyInconsistent() |
boolean |
isInterface() |
boolean |
isIntersectionType()
Returns true if the current type denotes an intersection type: Number & Comparable>
|
boolean |
isIntersectionType18() |
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 |
isPolyType() |
boolean |
isPotentiallyCompatibleWith(TypeBinding right,
Scope scope) |
boolean |
isPrimitiveOrBoxedPrimitiveType() |
boolean |
isPrimitiveType() |
boolean |
isProperType(boolean admitCapture18)
JLS8 Sect 18.1.1
|
boolean |
isProvablyDistinct(TypeBinding otherType)
Returns true if a type is provably distinct from another one,
|
boolean |
isRawType() |
boolean |
isReifiable()
JLS(3) 4.7.
|
boolean |
isRepeatableAnnotationType()
Answer true if the receiver is an annotation which may be repeatable.
|
boolean |
isStatic()
Answer true if the receiver is a static member type (or toplevel)
|
boolean |
isSubtypeOf(TypeBinding right) |
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 |
isUnresolvedType() |
boolean |
isWildcard()
Returns true if the type is a wildcard
|
int |
kind() |
TypeBinding |
leafComponentType() |
boolean |
mentionsAny(TypeBinding[] parameters,
int idx)
Does this type mention any of the given type parameters, except the one at position 'idx'?
|
boolean |
needsUncheckedConversion(TypeBinding targetType)
Meant to be invoked on compatible types, to figure if unchecked conversion is necessary
|
static boolean |
notEquals(TypeBinding that,
TypeBinding other) |
char[] |
nullAnnotatedReadableName(CompilerOptions options,
boolean shortNames)
Answer a readable name (for error reporting) that includes nullness type annotations.
|
TypeBinding |
original()
Returns the orignal generic type instantiated by the receiver type, or itself if not.
|
TypeBinding |
prototype()
Return the primordial type from which the receiver was cloned.
|
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.
|
void |
setTypeAnnotations(AnnotationBinding[] annotations,
boolean evalNullAnnotations) |
char[] |
signableName() |
char[] |
signature()
Answer the receiver classfile signature.
|
boolean |
sIsMoreSpecific(TypeBinding s,
TypeBinding t,
Scope scope) |
abstract char[] |
sourceName() |
ReferenceBinding |
superclass() |
ReferenceBinding[] |
superInterfaces() |
void |
swapUnresolved(UnresolvedReferenceBinding unresolvedType,
ReferenceBinding resolvedType,
LookupEnvironment environment) |
SyntheticArgumentBinding[] |
syntheticOuterLocalVariables() |
TypeVariableBinding[] |
typeVariables() |
TypeBinding |
unannotated()
Return this type minus its type annotations
|
TypeBinding |
uncapture(Scope scope)
Perform capture "deconversion" on a given type
|
long |
updateTagBits()
Refresh some tagBits from details into the main type.
|
static TypeBinding |
wellKnownType(Scope scope,
int id)
Match a well-known type id to its binding
|
TypeBinding |
withoutToplevelNullAnnotation()
Return this type minus its toplevel null annotations.
|
computeUniqueKey, computeUniqueKey, getAnnotations, getAnnotationTagBits, initializeDeprecatedAnnotationTagBits, isAnnotationType, isParameter, isTaggedRepeatable, isValidBinding, isVolatile, problemId, readableName, setAnnotations, setAnnotations, shortReadableNamepublic int id
public long tagBits
protected AnnotationBinding[] typeAnnotations
public static final ReferenceBinding TYPE_USE_BINDING
public static final BaseTypeBinding INT
public static final BaseTypeBinding BYTE
public static final BaseTypeBinding SHORT
public static final BaseTypeBinding CHAR
public static final BaseTypeBinding LONG
public static final BaseTypeBinding FLOAT
public static final BaseTypeBinding DOUBLE
public static final BaseTypeBinding BOOLEAN
public static final NullTypeBinding NULL
public static final VoidTypeBinding VOID
public TypeBinding()
public TypeBinding(TypeBinding prototype)
public static final TypeBinding wellKnownType(Scope scope, int id)
public ReferenceBinding actualType()
public java.lang.String annotatedDebugName()
public ReferenceBinding containerAnnotationType()
public boolean canBeInstantiated()
public TypeBinding capture(Scope scope, int start, int end)
public TypeBinding uncapture(Scope scope)
public TypeBinding closestMatch()
public java.util.List<TypeBinding> collectMissingTypes(java.util.List<TypeBinding> missingTypes)
missingTypes - public void collectSubstitutes(Scope scope, TypeBinding actualType, InferenceContext inferenceContext, int constraint)
public TypeBinding clone(TypeBinding enclosingType)
public abstract char[] constantPoolName()
public java.lang.String debugName()
public int dimensions()
public int depth()
public MethodBinding enclosingMethod()
public ReferenceBinding enclosingType()
public TypeBinding erasure()
public ReferenceBinding findSuperTypeOriginatingFrom(int wellKnownOriginalID, boolean originalIsClass)
TypeIdspublic TypeBinding findSuperTypeOriginatingFrom(TypeBinding otherType)
public TypeBinding genericCast(TypeBinding targetType)
public char[] genericTypeSignature()
public TypeBinding getErasureCompatibleType(TypeBinding declaringClass)
declaringClass - to look forpublic abstract PackageBinding getPackage()
public final boolean isAnonymousType()
public final boolean isArrayType()
public final boolean isBaseType()
public final boolean isPrimitiveType()
public final boolean isPrimitiveOrBoxedPrimitiveType()
public boolean isBoxedPrimitiveType()
public boolean isBoundParameterizedType()
public boolean isCapture()
public boolean isClass()
public boolean isCompatibleWith(TypeBinding right)
public abstract boolean isCompatibleWith(TypeBinding right, Scope scope)
public boolean isPotentiallyCompatibleWith(TypeBinding right, Scope scope)
public boolean isBoxingCompatibleWith(TypeBinding right, Scope scope)
public boolean isEnum()
public boolean isEquivalentTo(TypeBinding otherType)
public boolean isGenericType()
public final boolean isHierarchyInconsistent()
public boolean isInterface()
public boolean isFunctionalInterface(Scope scope)
public boolean isIntersectionType()
public final boolean isLocalType()
public final boolean isMemberType()
public final boolean isNestedType()
public final boolean isNumericType()
public boolean isParameterizedType()
isParameterizedTypeWithActualArguments() instead to find out.public boolean hasNullTypeAnnotations()
public boolean acceptsNonNullDefault()
public boolean isIntersectionType18()
public final boolean isParameterizedTypeWithActualArguments()
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_TYPEpublic boolean isParameterizedWithOwnVariables()
public boolean isProperType(boolean admitCapture18)
admitCapture18 - request if CaptureBinding18 shuld be considered as a proper type.
If unsure say 'true', only in Scope.greaterLowerBound(TypeBinding[], Scope, LookupEnvironment)
CaptureBinding18 has to be excluded to prevent an NPE on a branch that heuristically tries to avoid
inconsistent intersections.public boolean isPolyType()
public boolean isProvablyDistinct(TypeBinding otherType)
public boolean isRepeatableAnnotationType()
public final boolean isRawType()
public boolean isReifiable()
public boolean isStatic()
public boolean isThrowable()
public boolean isTypeArgumentContainedBy(TypeBinding otherType)
public boolean isTypeVariable()
public boolean isUnboundWildcard()
public boolean isUncheckedException(boolean includeSupertype)
public boolean isWildcard()
public TypeBinding leafComponentType()
public boolean needsUncheckedConversion(TypeBinding targetType)
public char[] nullAnnotatedReadableName(CompilerOptions options, boolean shortNames)
public TypeBinding original()
public TypeBinding unannotated()
public TypeBinding withoutToplevelNullAnnotation()
public final boolean hasTypeAnnotations()
public char[] qualifiedPackageName()
public abstract char[] qualifiedSourceName()
public final AnnotationBinding[] getTypeAnnotations()
public void setTypeAnnotations(AnnotationBinding[] annotations, boolean evalNullAnnotations)
public char[] signableName()
public char[] signature()
public abstract char[] sourceName()
public void swapUnresolved(UnresolvedReferenceBinding unresolvedType, ReferenceBinding resolvedType, LookupEnvironment environment)
public TypeVariableBinding[] typeVariables()
public MethodBinding getSingleAbstractMethod(Scope scope, boolean replaceWildcards)
null or ReferenceBinding.samProblemBinding, if the receiver is not a functional interface as defined in JLS 9.8.
In particular null is answered if the receiver is not a reference type, or is a problem type.scope - scopereplaceWildcards - Should wildcards be replaced following JLS 9.8? Say false for lambdas with explicit argument types which should apply 18.5.3null or ReferenceBinding.samProblemBinding, if the receiver is not a functional interface.public ReferenceBinding[] getIntersectingTypes()
public static boolean equalsEquals(TypeBinding that, TypeBinding other)
public static boolean notEquals(TypeBinding that, TypeBinding other)
public TypeBinding prototype()
SourceTypeBinding,
BinaryTypeBinding and UnresolvedReferenceBinding do so as of now. In fact some types e.g ParameterizedTypeBinding
should not do so. Deflecting a query to a prototype would lead to wrong results in the case of ParameterizedTypeBindingpublic boolean isUnresolvedType()
public boolean mentionsAny(TypeBinding[] parameters, int idx)
public boolean hasTypeBit(int bit)
TypeIds.BitAutoCloseable.public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope scope)
public boolean isSubtypeOf(TypeBinding right)
public MethodBinding[] getMethods(char[] selector)
public boolean canBeSeenBy(Scope scope)
public ReferenceBinding superclass()
public ReferenceBinding[] superInterfaces()
public SyntheticArgumentBinding[] syntheticOuterLocalVariables()
public boolean enterRecursiveFunction()
public void exitRecursiveFunction()
public boolean isFunctionalType()
public long updateTagBits()
public boolean isFreeTypeVariable()