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 NullnessAnnotatedTypeFactory |
nullnessTypeFactory
The type factory for the nullness analysis that was passed to the constructor.
|
protected AnnotationMirror |
POLYNULL
The @
PolyNull annotation. |
atypeFactoryanalysis, sequentialSemantics| Constructor and Description |
|---|
NullnessTransfer(NullnessAnalysis analysis)
Create a new NullnessTransfer for the given analysis.
|
initializedFieldsAfterCall, isNotFullyInitializedReceiver, markInvariantFieldsAsInitialized, visitAssignmentaddInformationFromPreconditions, createTransferResult, getNarrowedValue, getValueFromFactory, getWidenedValue, initialStore, insertIntoStores, moreSpecificValue, processCommonAssignment, processConditionalPostconditions, processPostconditions, recreateTransferResult, setFixedInitialStore, splitAssignments, usesSequentialSemantics, visitCase, visitClassName, visitConditionalNot, visitEqualTo, visitLambdaResultExpression, visitLocalVariable, visitNarrowingConversion, visitNode, visitNotEqual, visitObjectCreation, visitStringConcatenateAssignment, visitStringConversion, visitSwitchExpressionNode, visitTernaryExpression, visitThis, visitVariableDeclaration, visitWideningConversionvisitArrayCreation, 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, visitValueLiteralclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvisitArrayCreation, 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, visitUnsignedRightShiftprotected 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 NullnessAnnotatedTypeFactory nullnessTypeFactory
protected final @Nullable KeyForAnnotatedTypeFactory keyForTypeFactory
public NullnessTransfer(NullnessAnalysis analysis)
analysis - nullness analysisprotected 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)
CFAbstractTransfervalue 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)
CFAbstractTransfervalue 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.nullpublic 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)
InitializationTransfervisitFieldAccess 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>