Class InitializationTransfer<V extends CFAbstractValue<V>,T extends InitializationTransfer<V,T,S>,S extends InitializationStore<V,S>>
java.lang.Object
org.checkerframework.dataflow.cfg.node.AbstractNodeVisitor<TransferResult<V,S>,TransferInput<V,S>>
org.checkerframework.framework.flow.CFAbstractTransfer<V,S,T>
org.checkerframework.checker.initialization.InitializationTransfer<V,T,S>
- Type Parameters:
T
- the type of the transfer function
- All Implemented Interfaces:
ForwardTransferFunction<V,
,S> TransferFunction<V,
,S> NodeVisitor<TransferResult<V,
S>, TransferInput<V, S>>
- Direct Known Subclasses:
NullnessTransfer
public class InitializationTransfer<V extends CFAbstractValue<V>,T extends InitializationTransfer<V,T,S>,S extends InitializationStore<V,S>>
extends CFAbstractTransfer<V,S,T>
A transfer function that extends
CFAbstractTransfer
and tracks InitializationStore
s. In addition to the features of CFAbstractTransfer
, this transfer
function also tracks which fields of the current class ('self' receiver) have been initialized.
More precisely, the following refinements are performed:
- After the call to a constructor (
this()
call), all non-null fields of the current class can safely be considered initialized. - After a method call with a postcondition that ensures a field to be non-null, that field
can safely be considered initialized (this is done in
CFAbstractStore.insertValue(JavaExpression, CFAbstractValue)
). - All non-null fields with an initializer can be considered initialized (this is done in
CFAbstractStore.insertValue(JavaExpression, CFAbstractValue)
). - After the call to a super constructor ("super()" call), all non-null fields of the super class can safely be considered initialized.
- See Also:
-
Field Summary
Fields inherited from class org.checkerframework.framework.flow.CFAbstractTransfer
analysis, sequentialSemantics
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected List<VariableElement>
Returns the fields that can safely be considered initialized after the method callnode
.protected boolean
isNotFullyInitializedReceiver
(MethodTree methodTree) Returns true if the receiver of a method or constructor might not yet be fully initialized.protected void
markInvariantFieldsAsInitialized
(List<VariableElement> result, TypeElement clazzElem) Adds all the fields of the classclazzElem
that have the 'invariant annotation' to the set of initialized fieldsresult
.visitAssignment
(AssignmentNode n, TransferInput<V, S> in) If an invariant field is initialized and has the invariant annotation, than it has at least the invariant annotation.Methods inherited from class org.checkerframework.framework.flow.CFAbstractTransfer
addInformationFromPreconditions, createTransferResult, finishValue, finishValue, getNarrowedValue, getValueFromFactory, getWidenedValue, initialStore, insertIntoStores, moreSpecificValue, processCommonAssignment, processConditionalPostconditions, processPostconditions, recreateTransferResult, setFixedInitialStore, shouldPerformWholeProgramInference, shouldPerformWholeProgramInference, splitAssignments, strengthenAnnotationOfEqualTo, usesSequentialSemantics, visitArrayAccess, visitCase, visitClassName, visitConditionalNot, visitDeconstructorPattern, visitEqualTo, visitExpressionStatement, visitInstanceOf, visitLambdaResultExpression, visitLocalVariable, visitNarrowingConversion, visitNode, visitNotEqual, visitObjectCreation, visitReturn, visitStringConversion, visitSwitchExpressionNode, visitTernaryExpression, visitThis, visitVariableDeclaration, visitWideningConversion
Methods inherited from class org.checkerframework.dataflow.cfg.node.AbstractNodeVisitor
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, visitMethodAccess, visitNullChk, visitNullLiteral, visitNumericalAddition, visitNumericalMinus, visitNumericalMultiplication, visitNumericalPlus, visitNumericalSubtraction, visitPackageName, visitParameterizedType, visitPrimitiveType, visitShortLiteral, visitSignedRightShift, visitStringConcatenate, visitStringLiteral, visitSuper, visitSynchronized, visitThrow, visitTypeCast, visitUnsignedRightShift, visitValueLiteral
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.checkerframework.dataflow.cfg.node.NodeVisitor
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, visitMethodAccess, visitNullChk, visitNullLiteral, visitNumericalAddition, visitNumericalMinus, visitNumericalMultiplication, visitNumericalPlus, visitNumericalSubtraction, visitPackageName, visitParameterizedType, visitPrimitiveType, visitShortLiteral, visitSignedRightShift, visitStringConcatenate, visitStringLiteral, visitSuper, visitSynchronized, visitThrow, visitTypeCast, visitUnsignedRightShift
-
Field Details
-
atypeFactory
-
-
Constructor Details
-
InitializationTransfer
-
-
Method Details
-
isNotFullyInitializedReceiver
Description copied from class:CFAbstractTransfer
Returns true if the receiver of a method or constructor might not yet be fully initialized.- Overrides:
isNotFullyInitializedReceiver
in classCFAbstractTransfer<V extends CFAbstractValue<V>,
S extends InitializationStore<V, S>, T extends InitializationTransfer<V, T, S>> - Parameters:
methodTree
- the declaration of the method or constructor- Returns:
- true if the receiver of a method or constructor might not yet be fully initialized
-
initializedFieldsAfterCall
Returns the fields that can safely be considered initialized after the method callnode
.- Parameters:
node
- a method call- Returns:
- the fields that are initialized after the method call
-
markInvariantFieldsAsInitialized
protected void markInvariantFieldsAsInitialized(List<VariableElement> result, TypeElement clazzElem) Adds all the fields of the classclazzElem
that have the 'invariant annotation' to the set of initialized fieldsresult
. -
visitAssignment
- Specified by:
visitAssignment
in interfaceNodeVisitor<V extends CFAbstractValue<V>,
T extends InitializationTransfer<V, T, S>> - Overrides:
visitAssignment
in classCFAbstractTransfer<V extends CFAbstractValue<V>,
S extends InitializationStore<V, S>, T extends InitializationTransfer<V, T, S>>
-
visitFieldAccess
If an invariant field is initialized and has the invariant annotation, than it has at least the invariant annotation. Note that only fields of the 'this' receiver are tracked for initialization.- Specified by:
visitFieldAccess
in interfaceNodeVisitor<V extends CFAbstractValue<V>,
T extends InitializationTransfer<V, T, S>> - Overrides:
visitFieldAccess
in classCFAbstractTransfer<V extends CFAbstractValue<V>,
S extends InitializationStore<V, S>, T extends InitializationTransfer<V, T, S>>
-
visitMethodInvocation
- Specified by:
visitMethodInvocation
in interfaceNodeVisitor<V extends CFAbstractValue<V>,
T extends InitializationTransfer<V, T, S>> - Overrides:
visitMethodInvocation
in classCFAbstractTransfer<V extends CFAbstractValue<V>,
S extends InitializationStore<V, S>, T extends InitializationTransfer<V, T, S>>
-