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 |
protected javax.lang.model.element.AnnotationMirror |
NONNULL
Annotations of the non-null type system.
|
protected javax.lang.model.element.AnnotationMirror |
NULLABLE
Annotations of the non-null type system.
|
atypeFactory
analysis, sequentialSemantics
Constructor and Description |
---|
NullnessTransfer(NullnessAnalysis analysis) |
initializedFieldsAfterCall, isNotFullyInitializedReceiver, markInvariantFieldsAsInitialized, visitAssignment
addInformationFromPreconditions, finishValue, getTypeFactoryOfSubchecker, getValueFromFactory, getValueWithSameAnnotations, initialStore, moreSpecificValue, processCommonAssignment, processConditionalPostconditions, processPostconditions, setFixedInitialStore, splitAssignments, usesSequentialSemantics, visitCase, visitClassName, visitConditionalNot, visitEqualTo, visitLocalVariable, visitNarrowingConversion, visitNode, visitNotEqual, visitObjectCreation, visitStringConcatenateAssignment, visitStringConversion, visitTernaryExpression, visitThisLiteral, visitVariableDeclaration, visitWideningConversion
visitArrayCreation, visitArrayType, visitAssertionError, visitBitwiseAnd, visitBitwiseComplement, visitBitwiseOr, visitBitwiseXor, visitBooleanLiteral, visitCharacterLiteral, 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, 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 javax.lang.model.element.AnnotationMirror NONNULL
protected final javax.lang.model.element.AnnotationMirror NULLABLE
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 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 AbstractNodeVisitor<TransferResult<NullnessValue,NullnessStore>,TransferInput<NullnessValue,NullnessStore>>
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>