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 or Nullable
if the result is true.
NullPointerException
.
PolyNull
is known to be NonNull
or Nullable
(or not
known to be either).
Modifier and Type | Field and Description |
---|---|
protected @Nullable KeyForAnnotatedTypeFactory |
keyForTypeFactory
The type factory for the map key analysis, or null if the Map Key Checker should not be run.
|
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.
|
protected AnnotationMirror |
POLYNULL
The @
PolyNull annotation. |
atypeFactory
analysis, sequentialSemantics
Constructor and Description |
---|
NullnessTransfer(NullnessAnalysis analysis)
Create a new NullnessTransfer for the given analysis.
|
initializedFieldsAfterCall, isNotFullyInitializedReceiver, markInvariantFieldsAsInitialized, visitAssignment
addInformationFromPreconditions, createTransferResult, getNarrowedValue, getValueFromFactory, getValueWithSameAnnotations, getWidenedValue, initialStore, moreSpecificValue, processCommonAssignment, processConditionalPostconditions, processPostconditions, recreateTransferResult, setFixedInitialStore, splitAssignments, usesSequentialSemantics, visitCase, visitClassName, visitConditionalNot, visitEqualTo, visitLambdaResultExpression, visitLocalVariable, visitNarrowingConversion, visitNode, visitNotEqual, visitObjectCreation, visitStringConcatenateAssignment, visitStringConversion, visitTernaryExpression, visitThis, visitVariableDeclaration, visitWideningConversion
visitArrayCreation, visitArrayType, visitAssertionError, visitBitwiseAnd, visitBitwiseComplement, visitBitwiseOr, visitBitwiseXor, visitBooleanLiteral, visitCharacterLiteral, visitClassDeclaration, visitConditionalAnd, visitConditionalOr, visitDoubleLiteral, visitExplicitThis, visitFloatingDivision, visitFloatingRemainder, visitFloatLiteral, visitGreaterThan, visitGreaterThanOrEqual, visitImplicitThis, 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, visitExplicitThis, visitFloatingDivision, visitFloatingRemainder, visitFloatLiteral, visitGreaterThan, visitGreaterThanOrEqual, visitImplicitThis, 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 AnnotationMirror POLYNULL
PolyNull
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 @Nullable 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.store
- the store to updatenode
- the node that should be non-nullprotected void makeNonNull(TransferResult<NullnessValue,NullnessStore> result, Node node)
protected void refineToNonNull(TransferResult<NullnessValue,NullnessStore> result)
protected @Nullable NullnessValue finishValue(@Nullable NullnessValue value, NullnessStore store)
CFAbstractTransfer
value
as the result of the transfer function.
If a subclass overrides this method, the subclass should also override CFAbstractTransfer.finishValue(CFAbstractValue,CFAbstractStore,CFAbstractStore)
.
finishValue
in class CFAbstractTransfer<NullnessValue,NullnessStore,NullnessTransfer>
value
- a value to possibly modifystore
- the storeprotected @Nullable NullnessValue finishValue(@Nullable NullnessValue value, NullnessStore thenStore, NullnessStore elseStore)
CFAbstractTransfer
value
as the result of the transfer function.
If a subclass overrides this method, the subclass should also override CFAbstractTransfer.finishValue(CFAbstractValue,CFAbstractStore)
.
finishValue
in class CFAbstractTransfer<NullnessValue,NullnessStore,NullnessTransfer>
value
- the value to finishthenStore
- the "then" storeelseStore
- the "else" storeprotected 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). Clients usually call this twice
with firstNode
and secondNode
reversed, to refine each of them.
Note that when overriding this method, when a new type is inserted into the store, CFAbstractTransfer.splitAssignments(org.checkerframework.dataflow.cfg.node.Node)
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 resultfirstNode
- the node that might be more precisesecondNode
- the node whose type to possibly refinefirstValue
- the abstract value that might be more precisesecondValue
- the abstract value that might be less precisenotEqualTo
- 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>