org.aspectj.org.eclipse.jdt.internal.compiler.ast
Class NullAnnotationMatching

java.lang.Object
  extended by org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullAnnotationMatching

public class NullAnnotationMatching
extends java.lang.Object

Performs matching of null type annotations. Instances are used to encode result from this analysis.

Since:
3.10

Nested Class Summary
static class NullAnnotationMatching.CheckMode
           
 
Field Summary
static NullAnnotationMatching NULL_ANNOTATIONS_MISMATCH
           
static NullAnnotationMatching NULL_ANNOTATIONS_OK
           
static NullAnnotationMatching NULL_ANNOTATIONS_OK_NONNULL
           
static NullAnnotationMatching NULL_ANNOTATIONS_UNCHECKED
           
 int nullStatus
           
 int severity
          0 = OK, 1 = unchecked, 2 = definite mismatch
 TypeBinding superTypeHint
          If non-null this field holds the supertype of the provided type which was used for direct matching.
 
Constructor Summary
NullAnnotationMatching(int severity, int nullStatus, TypeBinding superTypeHint)
           
 
Method Summary
static NullAnnotationMatching analyse(TypeBinding requiredType, TypeBinding providedType, int nullStatus)
          Find any mismatches between the two given types, which are caused by null type annotations.
static NullAnnotationMatching analyse(TypeBinding requiredType, TypeBinding providedType, TypeBinding providedSubstitute, int nullStatus, NullAnnotationMatching.CheckMode mode)
          Find any mismatches between the two given types, which are caused by null type annotations.
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.
static int checkAssignment(BlockScope currentScope, FlowContext flowContext, VariableBinding var, int nullStatus, Expression expression, TypeBinding providedType)
          Check null-ness of 'var' against a possible null annotation
static MethodBinding checkForContraditions(MethodBinding method, InvocationSite invocationSite, Scope scope)
          After a method has substituted type parameters, check if this resulted in any contradictory null annotations.
 boolean isAnyMismatch()
           
 boolean isDefiniteMismatch()
           
 boolean isUnchecked()
           
static TypeBinding moreDangerousType(TypeBinding one, TypeBinding two)
          Provided that both types are TypeBinding.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.
 java.lang.String superTypeHintName(CompilerOptions options, boolean shortNames)
           
static long validNullTagBits(long bits)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_ANNOTATIONS_OK

public static final NullAnnotationMatching NULL_ANNOTATIONS_OK

NULL_ANNOTATIONS_OK_NONNULL

public static final NullAnnotationMatching NULL_ANNOTATIONS_OK_NONNULL

NULL_ANNOTATIONS_UNCHECKED

public static final NullAnnotationMatching NULL_ANNOTATIONS_UNCHECKED

NULL_ANNOTATIONS_MISMATCH

public static final NullAnnotationMatching NULL_ANNOTATIONS_MISMATCH

severity

public final int severity
0 = OK, 1 = unchecked, 2 = definite mismatch


superTypeHint

public final TypeBinding superTypeHint
If non-null this field holds the supertype of the provided type which was used for direct matching.


nullStatus

public final int nullStatus
Constructor Detail

NullAnnotationMatching

public NullAnnotationMatching(int severity,
                              int nullStatus,
                              TypeBinding superTypeHint)
Method Detail

isAnyMismatch

public boolean isAnyMismatch()

isUnchecked

public boolean isUnchecked()

isDefiniteMismatch

public boolean isDefiniteMismatch()

superTypeHintName

public java.lang.String superTypeHintName(CompilerOptions options,
                                          boolean shortNames)

checkAssignment

public static int checkAssignment(BlockScope currentScope,
                                  FlowContext flowContext,
                                  VariableBinding var,
                                  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:
requiredType -
providedType -
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,
                                             int nullStatus,
                                             NullAnnotationMatching.CheckMode mode)
Find any mismatches between the two given types, which are caused by null type annotations.

Parameters:
requiredType -
providedType -
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.
nullStatus - we are only interested in NULL or NON_NULL, -1 indicates that we are in a recursion, where flow info is ignored
mode - controls the kind of check performed (see NullAnnotationMatching.CheckMode).
Returns:
a status object representing the severity of mismatching plus optionally a supertype hint

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.


validNullTagBits

public static long validNullTagBits(long bits)

moreDangerousType

public static TypeBinding moreDangerousType(TypeBinding one,
                                            TypeBinding two)
Provided that both types are TypeBinding.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.


checkForContraditions

public static MethodBinding checkForContraditions(MethodBinding method,
                                                  InvocationSite invocationSite,
                                                  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.