Class NullAnnotationMatching
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching
Performs matching of null type annotations.
Instances are used to encode result from this analysis.
- Since:
- 3.10
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final NullAnnotationMatchingstatic final NullAnnotationMatchingstatic final NullAnnotationMatchingstatic final NullAnnotationMatchingfinal intfinal TypeBindingIf non-null this field holds the supertype of the provided type which was used for direct matching. -
Method Summary
Modifier and TypeMethodDescriptionstatic NullAnnotationMatchinganalyse(TypeBinding requiredType, TypeBinding providedType, int nullStatus) Find any mismatches between the two given types, which are caused by null type annotations.static NullAnnotationMatchinganalyse(TypeBinding requiredType, TypeBinding providedType, TypeBinding providedSubstitute, Substitution substitution, int nullStatus, Expression providedExpression, NullAnnotationMatching.CheckMode mode) Find any mismatches between the two given types, which are caused by null type annotations.protected static booleanareSameTypes(TypeBinding requiredType, TypeBinding providedType, TypeBinding providedSubstitute) Are both types identical wrt the unannotated type and any null type annotations? Only unstructured types and captures are considered.static intcheckAssignment(BlockScope currentScope, FlowContext flowContext, VariableBinding var, FlowInfo flowInfo, int nullStatus, Expression expression, TypeBinding providedType) Check null-ness of 'var' against a possible null annotationstatic MethodBindingcheckForContradictions(MethodBinding method, Object location, Scope scope) After a method has substituted type parameters, check if this resulted in any contradictory null annotations.intgetProblemId(TypeBinding requiredType) static booleanhasContradictions(TypeBinding type) static booleanHelp Scope.mostSpecificMethodBinding(MethodBinding[], int, TypeBinding[], InvocationSite, ReferenceBinding): If choice between equivalent methods would otherwise be arbitrary, determine if m1 should be preferred due to a more specific null contract.booleanbooleanbooleanbooleanbooleanstatic TypeBindingmoreDangerousType(TypeBinding one, TypeBinding two) Provided that both types areTypeBinding.equalsEquals(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding), return the one that is more likely to show null at runtime.static intUse only if no suitable flowInfo is available.static NullAnnotationMatchingokNonNullStatus(Expression providedExpression) voidstatic TypeBindingstrongerType(TypeBinding type1, TypeBinding type2, LookupEnvironment environment) superTypeHintName(CompilerOptions options, boolean shortNames) toString()static longvalidNullTagBits(long bits) booleanstatic TypeBinding[]weakerTypes(TypeBinding[] parameters1, TypeBinding[] parameters2, LookupEnvironment environment) withNullStatus(int updatedNullStatus) For creating updated status during *FlowContext.complainOnDeferred*Checks() once the actual nullStatus is known
-
Field Details
-
NULL_ANNOTATIONS_OK
-
NULL_ANNOTATIONS_OK_NONNULL
-
NULL_ANNOTATIONS_UNCHECKED
-
NULL_ANNOTATIONS_MISMATCH
-
superTypeHint
If non-null this field holds the supertype of the provided type which was used for direct matching. -
nullStatus
public final int nullStatus
-
-
Method Details
-
withNullStatus
For creating updated status during *FlowContext.complainOnDeferred*Checks() once the actual nullStatus is known -
isAnyMismatch
public boolean isAnyMismatch() -
isUnchecked
public boolean isUnchecked() -
isAnnotatedToUnannotated
public boolean isAnnotatedToUnannotated() -
isDefiniteMismatch
public boolean isDefiniteMismatch() -
wantToReport
public boolean wantToReport() -
isPotentiallyNullMismatch
public boolean isPotentiallyNullMismatch() -
superTypeHintName
-
checkAssignment
public static int checkAssignment(BlockScope currentScope, FlowContext flowContext, VariableBinding var, FlowInfo flowInfo, int nullStatus, Expression expression, TypeBinding providedType) Check null-ness of 'var' against a possible null annotation -
analyse
public static NullAnnotationMatching analyse(TypeBinding requiredType, TypeBinding providedType, int nullStatus) Find any mismatches between the two given types, which are caused by null type annotations.- Parameters:
nullStatus- we are only interested in NULL or NON_NULL, -1 indicates that we are in a recursion, where flow info is ignored- Returns:
- a status object representing the severity of mismatching plus optionally a supertype hint
-
analyse
public static NullAnnotationMatching analyse(TypeBinding requiredType, TypeBinding providedType, TypeBinding providedSubstitute, Substitution substitution, int nullStatus, Expression providedExpression, NullAnnotationMatching.CheckMode mode) Find any mismatches between the two given types, which are caused by null type annotations.- Parameters:
providedSubstitute- in inheritance situations this maps the providedType into the realm of the subclass, needed for TVB identity checks. Pass null if not interested in these added checks.substitution- TODOnullStatus- we are only interested in NULL or NON_NULL, -1 indicates that we are in a recursion, where flow info is ignoredprovidedExpression- optionally holds the provided expression of type 'providedType'mode- controls the kind of check performed (seeNullAnnotationMatching.CheckMode).- Returns:
- a status object representing the severity of mismatching plus optionally a supertype hint
-
report
-
getProblemId
-
okNonNullStatus
-
areSameTypes
protected static boolean areSameTypes(TypeBinding requiredType, TypeBinding providedType, TypeBinding providedSubstitute) Are both types identical wrt the unannotated type and any null type annotations? Only unstructured types and captures are considered. -
nullStatusFromExpressionType
Use only if no suitable flowInfo is available. -
validNullTagBits
public static long validNullTagBits(long bits) -
moreDangerousType
Provided that both types areTypeBinding.equalsEquals(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding), return the one that is more likely to show null at runtime. -
checkForContradictions
public static MethodBinding checkForContradictions(MethodBinding method, Object location, Scope scope) After a method has substituted type parameters, check if this resulted in any contradictory null annotations. Problems are either reported directly (if scope != null) or by returning a ProblemMethodBinding. -
hasContradictions
-
strongerType
public static TypeBinding strongerType(TypeBinding type1, TypeBinding type2, LookupEnvironment environment) -
weakerTypes
public static TypeBinding[] weakerTypes(TypeBinding[] parameters1, TypeBinding[] parameters2, LookupEnvironment environment) -
hasMoreSpecificNullness
Help Scope.mostSpecificMethodBinding(MethodBinding[], int, TypeBinding[], InvocationSite, ReferenceBinding): If choice between equivalent methods would otherwise be arbitrary, determine if m1 should be preferred due to a more specific null contract. -
toString
-