public class NullnessTransfer extends InitializationTransfer<NullnessValue,NullnessTransfer,NullnessStore>
null
literal, then that expression can
safely be considered NonNull
if the result of the comparison is false.
NullPointerException
.
PolyNull
is known to be Nullable
.
Modifier and Type | Field and Description |
---|---|
protected KeyForAnnotatedTypeFactory |
keyForTypeFactory
The type factory for the map key analysis.
|
protected AnnotatedTypeMirror.AnnotatedDeclaredType |
MAP_TYPE
Java's Map interface.
|
protected AnnotationMirror |
NONNULL
The @
NonNull annotation. |
protected AnnotationMirror |
NULLABLE
The @
Nullable annotation. |
protected GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,? extends CFAbstractAnalysis<NullnessValue,NullnessStore,NullnessTransfer>> |
nullnessTypeFactory
The type factory for the nullness analysis that was passed to the constructor.
|
atypeFactory
analysis, sequentialSemantics
Constructor and Description |
---|
NullnessTransfer(NullnessAnalysis analysis)
Create a new NullnessTransfer for the given analysis.
|
initializedFieldsAfterCall, isNotFullyInitializedReceiver, markInvariantFieldsAsInitialized, visitAssignment
addInformationFromPreconditions, finishValue, getValueFromFactory, getValueWithSameAnnotations, initialStore, moreSpecificValue, processCommonAssignment, processConditionalPostconditions, processPostconditions, setFixedInitialStore, splitAssignments, usesSequentialSemantics, visitCase, visitClassName, visitConditionalNot, visitEqualTo, visitLambdaResultExpression, visitLocalVariable, visitNarrowingConversion, visitNode, visitNotEqual, visitObjectCreation, visitStringConcatenateAssignment, visitStringConversion, visitTernaryExpression, visitThisLiteral, visitVariableDeclaration, visitWideningConversion
visitArrayCreation, visitArrayType, visitAssertionError, visitBitwiseAnd, visitBitwiseComplement, visitBitwiseOr, visitBitwiseXor, visitBooleanLiteral, visitCharacterLiteral, visitClassDeclaration, visitConditionalAnd, visitConditionalOr, visitDoubleLiteral, visitExplicitThisLiteral, visitFloatingDivision, visitFloatingRemainder, visitFloatLiteral, visitGreaterThan, visitGreaterThanOrEqual, visitImplicitThisLiteral, visitIntegerDivision, visitIntegerLiteral, visitIntegerRemainder, visitLeftShift, visitLessThan, visitLessThanOrEqual, visitLongLiteral, visitMarker, visitMemberReference, visitNullChk, visitNullLiteral, visitNumericalAddition, visitNumericalMinus, visitNumericalMultiplication, visitNumericalPlus, visitNumericalSubtraction, visitPackageName, visitParameterizedType, visitPrimitiveType, visitShortLiteral, visitSignedRightShift, visitStringConcatenate, visitStringLiteral, visitSuper, visitSynchronized, visitTypeCast, visitUnsignedRightShift, visitValueLiteral
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
visitArrayCreation, visitArrayType, visitAssertionError, visitBitwiseAnd, visitBitwiseComplement, visitBitwiseOr, visitBitwiseXor, visitBooleanLiteral, visitCharacterLiteral, visitClassDeclaration, visitConditionalAnd, visitConditionalOr, visitDoubleLiteral, visitExplicitThisLiteral, visitFloatingDivision, visitFloatingRemainder, visitFloatLiteral, visitGreaterThan, visitGreaterThanOrEqual, visitImplicitThisLiteral, visitIntegerDivision, visitIntegerLiteral, visitIntegerRemainder, visitLeftShift, visitLessThan, visitLessThanOrEqual, visitLongLiteral, visitMarker, visitMemberReference, visitNullChk, visitNullLiteral, visitNumericalAddition, visitNumericalMinus, visitNumericalMultiplication, visitNumericalPlus, visitNumericalSubtraction, visitPackageName, visitParameterizedType, visitPrimitiveType, visitShortLiteral, visitSignedRightShift, visitStringConcatenate, visitStringLiteral, visitSuper, visitSynchronized, visitTypeCast, visitUnsignedRightShift
protected final AnnotationMirror NONNULL
NonNull
annotation.protected final AnnotationMirror NULLABLE
Nullable
annotation.protected final AnnotatedTypeMirror.AnnotatedDeclaredType MAP_TYPE
The qualifiers in this type don't matter -- it is not used as a fully-annotated AnnotatedDeclaredType, but just passed to asSuper().
protected final GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,? extends CFAbstractAnalysis<NullnessValue,NullnessStore,NullnessTransfer>> nullnessTypeFactory
protected final KeyForAnnotatedTypeFactory keyForTypeFactory
public NullnessTransfer(NullnessAnalysis analysis)
protected void makeNonNull(NullnessStore store, Node node)
Node
to non-null in the given store
. Calls to this method
implement case 2.protected void makeNonNull(TransferResult<NullnessValue,NullnessStore> result, Node node)
protected void refineToNonNull(TransferResult<NullnessValue,NullnessStore> result)
protected NullnessValue finishValue(NullnessValue value, NullnessStore store)
CFAbstractTransfer
value
as the result of the
transfer function. By default, the value is not changed but subclasses might decide to
implement some functionality. The store at this position is also passed.finishValue
in class CFAbstractTransfer<NullnessValue,NullnessStore,NullnessTransfer>
protected TransferResult<NullnessValue,NullnessStore> strengthenAnnotationOfEqualTo(TransferResult<NullnessValue,NullnessStore> res, Node firstNode, Node secondNode, NullnessValue firstValue, NullnessValue secondValue, boolean notEqualTo)
secondNode
if the annotation secondValue
is less
precise than firstValue
. This is possible, if secondNode
is an expression
that is tracked by the store (e.g., a local variable or a field).
Note that when overriding this method, when a new type is inserted into the store, splitAssignments should be called, and the new type should be inserted into the store for each of the resulting nodes.
Furthermore, this method refines the type to NonNull
for the appropriate branch if
an expression is compared to the null
literal (listed as case 1 in the class
description).
strengthenAnnotationOfEqualTo
in class CFAbstractTransfer<NullnessValue,NullnessStore,NullnessTransfer>
res
- the previous resultnotEqualTo
- if true, indicates that the logic is flipped (i.e., the information is
added to the elseStore
instead of the thenStore
) for a not-equal
comparison.null
.public TransferResult<NullnessValue,NullnessStore> visitArrayAccess(ArrayAccessNode n, TransferInput<NullnessValue,NullnessStore> p)
visitArrayAccess
in interface NodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
visitArrayAccess
in class CFAbstractTransfer<NullnessValue,NullnessStore,NullnessTransfer>
public TransferResult<NullnessValue,NullnessStore> visitInstanceOf(InstanceOfNode n, TransferInput<NullnessValue,NullnessStore> p)
visitInstanceOf
in interface NodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
visitInstanceOf
in class CFAbstractTransfer<NullnessValue,NullnessStore,NullnessTransfer>
public TransferResult<NullnessValue,NullnessStore> visitMethodAccess(MethodAccessNode n, TransferInput<NullnessValue,NullnessStore> p)
visitMethodAccess
in interface NodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
visitMethodAccess
in class AbstractNodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
public TransferResult<NullnessValue,NullnessStore> visitFieldAccess(FieldAccessNode n, TransferInput<NullnessValue,NullnessStore> p)
InitializationTransfer
visitFieldAccess
in interface NodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
visitFieldAccess
in class InitializationTransfer<NullnessValue,NullnessTransfer,NullnessStore>
public TransferResult<NullnessValue,NullnessStore> visitThrow(ThrowNode n, TransferInput<NullnessValue,NullnessStore> p)
visitThrow
in interface NodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
visitThrow
in class AbstractNodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
public TransferResult<NullnessValue,NullnessStore> visitMethodInvocation(MethodInvocationNode n, TransferInput<NullnessValue,NullnessStore> in)
visitMethodInvocation
in interface NodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
visitMethodInvocation
in class InitializationTransfer<NullnessValue,NullnessTransfer,NullnessStore>
public TransferResult<NullnessValue,NullnessStore> visitReturn(ReturnNode n, TransferInput<NullnessValue,NullnessStore> in)
visitReturn
in interface NodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
visitReturn
in class CFAbstractTransfer<NullnessValue,NullnessStore,NullnessTransfer>