Class NullnessTransfer
- All Implemented Interfaces:
- ForwardTransferFunction<NullnessValue,,- NullnessStore> - TransferFunction<NullnessValue,,- NullnessStore> - NodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
- After an expression is compared with the nullliteral, then that expression can safely be consideredNonNullif the result of the comparison is false orNullableif the result is true.
- If an expression is dereferenced, then it can safely be assumed to non-null in the future.
       If it would not be, then the dereference would have raised a NullPointerException.
- Tracks whether PolyNullis known to beNonNullorNullable(or not known to be either).
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final @Nullable KeyForAnnotatedTypeFactoryThe type factory for the map key analysis, or null if the Map Key Checker should not be run.protected final AnnotatedTypeMirror.AnnotatedDeclaredTypeJava's Map interface.protected final AnnotationMirrorThe @NonNullannotation.protected final AnnotationMirrorThe @Nullableannotation.protected final NullnessAnnotatedTypeFactoryThe type factory for the nullness analysis that was passed to the constructor.protected final AnnotationMirrorThe @PolyNullannotation.Fields inherited from class org.checkerframework.checker.initialization.InitializationTransferatypeFactoryFields inherited from class org.checkerframework.framework.flow.CFAbstractTransferanalysis, sequentialSemantics
- 
Constructor SummaryConstructorsConstructorDescriptionNullnessTransfer(NullnessAnalysis analysis) Create a new NullnessTransfer for the given analysis.
- 
Method SummaryModifier and TypeMethodDescriptionprotected @Nullable NullnessValuefinishValue(@Nullable NullnessValue value, NullnessStore store) A hook for subclasses to modify the result of the transfer function.protected @Nullable NullnessValuefinishValue(@Nullable NullnessValue value, NullnessStore thenStore, NullnessStore elseStore) A hook for subclasses to modify the result of the transfer function.protected voidmakeNonNull(NullnessStore store, Node node) Sets a givenNodeto non-null in the givenstore.protected voidmakeNonNull(TransferResult<NullnessValue, NullnessStore> result, Node node) protected voidRefine the given result to @NonNull.protected TransferResult<NullnessValue,NullnessStore> strengthenAnnotationOfEqualTo(TransferResult<NullnessValue, NullnessStore> res, Node firstNode, Node secondNode, NullnessValue firstValue, NullnessValue secondValue, boolean notEqualTo) Refine the annotation ofsecondNodeif the annotationsecondValueis less precise thanfirstValue.If an invariant field is initialized and has the invariant annotation, then it has at least the invariant annotation.Methods inherited from class org.checkerframework.checker.initialization.InitializationTransferinitializedFieldsAfterCall, isNotFullyInitializedReceiver, markInvariantFieldsAsInitialized, visitAssignmentMethods inherited from class org.checkerframework.framework.flow.CFAbstractTransferaddInformationFromPreconditions, createTransferResult, createTransferResult, getNarrowedValue, getValueFromFactory, getWidenedValue, initialStore, insertIntoStores, moreSpecificValue, processCommonAssignment, processConditionalPostconditions, processPostconditions, recreateTransferResult, recreateTransferResult, setFixedInitialStore, shouldPerformWholeProgramInference, shouldPerformWholeProgramInference, splitAssignments, usesSequentialSemantics, visitCase, visitClassName, visitConditionalNot, visitDeconstructorPattern, visitEqualTo, visitExpressionStatement, visitLambdaResultExpression, visitLocalVariable, visitNarrowingConversion, visitNode, visitNotEqual, visitObjectCreation, visitStringConversion, visitSwitchExpressionNode, visitTernaryExpression, visitThis, visitVariableDeclaration, visitWideningConversionMethods inherited from class org.checkerframework.dataflow.cfg.node.AbstractNodeVisitorvisitArrayCreation, 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, visitValueLiteralMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.checkerframework.dataflow.cfg.node.NodeVisitorvisitArrayCreation, 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
- 
Field Details- 
NONNULLThe @NonNullannotation.
- 
NULLABLEThe @Nullableannotation.
- 
POLYNULLThe @PolyNullannotation.
- 
MAP_TYPEJava's Map interface.The qualifiers in this type don't matter -- it is not used as a fully-annotated AnnotatedDeclaredType, but just passed to asSuper(). 
- 
nullnessTypeFactoryThe type factory for the nullness analysis that was passed to the constructor.
- 
keyForTypeFactoryThe type factory for the map key analysis, or null if the Map Key Checker should not be run.
 
- 
- 
Constructor Details- 
NullnessTransferCreate a new NullnessTransfer for the given analysis.- Parameters:
- analysis- nullness analysis
 
 
- 
- 
Method Details- 
makeNonNullSets a givenNodeto non-null in the givenstore. Calls to this method implement case 2.- Parameters:
- store- the store to update
- node- the node that should be non-null
 
- 
makeNonNull
- 
refineToNonNullRefine the given result to @NonNull.
- 
finishValueDescription copied from class:CFAbstractTransferA hook for subclasses to modify the result of the transfer function. This method is called before returning the abstract valuevalueas the result of the transfer function.If a subclass overrides this method, the subclass should also override CFAbstractTransfer.finishValue(CFAbstractValue,CFAbstractStore,CFAbstractStore).- Overrides:
- finishValuein class- CFAbstractTransfer<NullnessValue,- NullnessStore, - NullnessTransfer> 
- Parameters:
- value- a value to possibly modify
- store- the store
- Returns:
- the possibly-modified value
 
- 
finishValueprotected @Nullable NullnessValue finishValue(@Nullable NullnessValue value, NullnessStore thenStore, NullnessStore elseStore) Description copied from class:CFAbstractTransferA hook for subclasses to modify the result of the transfer function. This method is called before returning the abstract valuevalueas the result of the transfer function.If a subclass overrides this method, the subclass should also override CFAbstractTransfer.finishValue(CFAbstractValue,CFAbstractStore).- Overrides:
- finishValuein class- CFAbstractTransfer<NullnessValue,- NullnessStore, - NullnessTransfer> 
- Parameters:
- value- the value to finish
- thenStore- the "then" store
- elseStore- the "else" store
- Returns:
- the possibly-modified value
 
- 
strengthenAnnotationOfEqualToprotected TransferResult<NullnessValue,NullnessStore> strengthenAnnotationOfEqualTo(TransferResult<NullnessValue, NullnessStore> res, Node firstNode, Node secondNode, NullnessValue firstValue, NullnessValue secondValue, boolean notEqualTo) Refine the annotation ofsecondNodeif the annotationsecondValueis less precise thanfirstValue. This is possible, ifsecondNodeis an expression that is tracked by the store (e.g., a local variable or a field). Clients usually call this twice withfirstNodeandsecondNodereversed, 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 NonNullfor the appropriate branch if an expression is compared to thenullliteral (listed as case 1 in the class description).- Overrides:
- strengthenAnnotationOfEqualToin class- CFAbstractTransfer<NullnessValue,- NullnessStore, - NullnessTransfer> 
- Parameters:
- res- the previous result
- firstNode- the node that might be more precise
- secondNode- the node whose type to possibly refine
- firstValue- the abstract value that might be more precise
- secondValue- the abstract value that might be less precise
- notEqualTo- if true, indicates that the logic is flipped (i.e., the information is added to the- elseStoreinstead of the- thenStore) for a not-equal comparison.
- Returns:
- the conditional transfer result (if information has been added), or res
 
- 
visitArrayAccesspublic TransferResult<NullnessValue,NullnessStore> visitArrayAccess(ArrayAccessNode n, TransferInput<NullnessValue, NullnessStore> p) - Specified by:
- visitArrayAccessin interface- NodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
- Overrides:
- visitArrayAccessin class- CFAbstractTransfer<NullnessValue,- NullnessStore, - NullnessTransfer> 
 
- 
visitInstanceOfpublic TransferResult<NullnessValue,NullnessStore> visitInstanceOf(InstanceOfNode n, TransferInput<NullnessValue, NullnessStore> p) - Specified by:
- visitInstanceOfin interface- NodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
- Overrides:
- visitInstanceOfin class- CFAbstractTransfer<NullnessValue,- NullnessStore, - NullnessTransfer> 
 
- 
visitMethodAccesspublic TransferResult<NullnessValue,NullnessStore> visitMethodAccess(MethodAccessNode n, TransferInput<NullnessValue, NullnessStore> p) - Specified by:
- visitMethodAccessin interface- NodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
- Overrides:
- visitMethodAccessin class- AbstractNodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
 
- 
visitFieldAccesspublic TransferResult<NullnessValue,NullnessStore> visitFieldAccess(FieldAccessNode n, TransferInput<NullnessValue, NullnessStore> p) Description copied from class:InitializationTransferIf an invariant field is initialized and has the invariant annotation, then it has at least the invariant annotation. Note that only fields of the 'this' receiver are tracked for initialization.- Specified by:
- visitFieldAccessin interface- NodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
- Overrides:
- visitFieldAccessin class- InitializationTransfer<NullnessValue,- NullnessTransfer, - NullnessStore> 
 
- 
visitThrowpublic TransferResult<NullnessValue,NullnessStore> visitThrow(ThrowNode n, TransferInput<NullnessValue, NullnessStore> p) - Specified by:
- visitThrowin interface- NodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
- Overrides:
- visitThrowin class- AbstractNodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
 
- 
visitMethodInvocationpublic TransferResult<NullnessValue,NullnessStore> visitMethodInvocation(MethodInvocationNode n, TransferInput<NullnessValue, NullnessStore> in) When the invocationPreservesArgumentNullness flag is turned on, the receiver and arguments that are passed to non-null parameters in a method call or constructor invocation are unsoundly assumed to be non-null after the invocation. When the flag is turned off, the analysis is sound: it checks that the method is SideEffectFree or the receiver is unassignable. Only if either one of the two is true, is the receiver made non-null. Similar logic is applied to the arguments of the invocation. Provided that m is of a type that implements interface java.util.Map: - Given a call m.get(k), if k is @KeyFor("m") and m's value type is @NonNull, then the result is @NonNull in the thenStore and elseStore of the transfer result.
 - Specified by:
- visitMethodInvocationin interface- NodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
- Overrides:
- visitMethodInvocationin class- InitializationTransfer<NullnessValue,- NullnessTransfer, - NullnessStore> 
 
- 
visitReturnpublic TransferResult<NullnessValue,NullnessStore> visitReturn(ReturnNode n, TransferInput<NullnessValue, NullnessStore> in) - Specified by:
- visitReturnin interface- NodeVisitor<TransferResult<NullnessValue,- NullnessStore>, - TransferInput<NullnessValue, - NullnessStore>> 
- Overrides:
- visitReturnin class- CFAbstractTransfer<NullnessValue,- NullnessStore, - NullnessTransfer> 
 
 
-