Interface WholeProgramInference
- All Known Implementing Classes:
- WholeProgramInferenceImplementation
WholeProgramInference is misleading.
 This interface has update* methods that should be called at certain (pseudo-)assignments, and they may update the type of the LHS of the (pseudo-)assignment based on the type of the RHS. In case the element on the LHS already had an inferred type, its new type will be the LUB between the previous and new types.
- See the Checker Framework Manual:
- Whole-program inference
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic enumThe kinds of output that whole-program inference can produce.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddClassDeclarationAnnotation(TypeElement classElt, AnnotationMirror anno) Adds an annotation to a class declaration.voidaddDeclarationAnnotationToFormalParameter(ExecutableElement methodElt, int index, AnnotationMirror anno) Adds a declaration annotation to a formal parameter.voidaddFieldDeclarationAnnotation(VariableElement fieldElt, AnnotationMirror anno) Updates a field to add a declaration annotation.voidaddMethodDeclarationAnnotation(ExecutableElement methodElt, AnnotationMirror anno) Updates a method to add a declaration annotation.voidpreprocessClassTree(ClassTree classTree) Performs any preparation required for inference on Elements of a class.voidupdateContracts(Analysis.BeforeOrAfter preOrPost, ExecutableElement methodElement, CFAbstractStore<?, ?> store) Updates the preconditions or postconditions of the current method, from a store.voidupdateFieldFromType(Tree lhsTree, Element element, String fieldName, AnnotatedTypeMirror rhsATM) Updates the type offieldbased on an assignment whose right-hand side has typerhsATM.voidupdateFromFieldAssignment(Node field, Node rhs) Updates the type offieldbased on an assignment ofrhstofield.voidupdateFromFormalParameterAssignment(LocalVariableNode lhs, Node rhs, VariableElement paramElt) Updates the type oflhsbased on an assignment ofrhstolhs.voidupdateFromMethodInvocation(MethodInvocationNode methodInvNode, ExecutableElement methodElt, CFAbstractStore<?, ?> store) Updates the parameter types of the methodmethodEltbased on the arguments in the method invocationmethodInvNode.voidupdateFromObjectCreation(ObjectCreationNode objectCreationNode, ExecutableElement constructorElt, CFAbstractStore<?, ?> store) Updates the parameter types of the constructorconstructorEltbased on the arguments inobjectCreationNode.voidupdateFromOverride(MethodTree methodTree, ExecutableElement methodElt, AnnotatedTypeMirror.AnnotatedExecutableType overriddenMethod) Updates the parameter types (including the receiver) of the methodmethodTreebased on the parameter types of the overridden methodoverriddenMethod.voidupdateFromReturn(ReturnNode retNode, com.sun.tools.javac.code.Symbol.ClassSymbol classSymbol, MethodTree methodTree, Map<AnnotatedTypeMirror.AnnotatedDeclaredType, ExecutableElement> overriddenMethods) Updates the return type of the methodmethodTreebased onreturnedExpression.voidwriteResultsToFile(WholeProgramInference.OutputFormat format, BaseTypeChecker checker) Writes the inferred results to a file.
- 
Method Details- 
updateFromObjectCreationvoid updateFromObjectCreation(ObjectCreationNode objectCreationNode, ExecutableElement constructorElt, CFAbstractStore<?, ?> store) Updates the parameter types of the constructorconstructorEltbased on the arguments inobjectCreationNode.For each parameter in constructorElt: - If there is no stored annotated type for that parameter, then use the type of the corresponding argument in the object creation call objectCreationNode.
- If there was a stored annotated type for that parameter, then its new type will be the LUB between the previous type and the type of the corresponding argument in the object creation call.
 - Parameters:
- objectCreationNode- the Node that invokes the constructor
- constructorElt- the Element of the constructor
- store- the store just before the call
 
- 
updateFromMethodInvocationvoid updateFromMethodInvocation(MethodInvocationNode methodInvNode, ExecutableElement methodElt, CFAbstractStore<?, ?> store) Updates the parameter types of the methodmethodEltbased on the arguments in the method invocationmethodInvNode.For each formal parameter in methodElt (including the receiver): - If there is no stored annotated type for that parameter, then use the type of the corresponding argument in the method call methodInvNode.
- If there was a stored annotated type for that parameter, then its new type will be the LUB between the previous type and the type of the corresponding argument in the method call.
 - Parameters:
- methodInvNode- the node representing a method invocation
- methodElt- the element of the method being invoked
- store- the store before the method call, used for inferring method preconditions
 
- 
updateFromOverridevoid updateFromOverride(MethodTree methodTree, ExecutableElement methodElt, AnnotatedTypeMirror.AnnotatedExecutableType overriddenMethod) Updates the parameter types (including the receiver) of the methodmethodTreebased on the parameter types of the overridden methodoverriddenMethod.For each formal parameter in methodElt: - If there is no stored annotated type for that parameter, then use the type of the corresponding parameter on the overridden method.
- If there is a stored annotated type for that parameter, then its new type will be the LUB between the previous type and the type of the corresponding parameter on the overridden method.
 - Parameters:
- methodTree- the tree of the method that contains the parameter(s)
- methodElt- the element of the method
- overriddenMethod- the AnnotatedExecutableType of the overridden method
 
- 
updateFromFormalParameterAssignmentUpdates the type oflhsbased on an assignment ofrhstolhs.- If there is no stored annotated type for lhs, then use the type of the corresponding argument in the method call methodInvNode.
- If there is a stored annotated type for lhs, then its new type will be the LUB between the previous type and the type of the corresponding argument in the method call.
 - Parameters:
- lhs- the node representing the formal parameter
- rhs- the node being assigned to the parameter in the method body
- paramElt- the formal parameter
 
- 
updateFromFieldAssignmentUpdates the type offieldbased on an assignment ofrhstofield. If the field has a declaration annotation with theIgnoreInWholeProgramInferencemeta-annotation, no type annotation will be inferred for that field.If there is no stored entry for the field lhs, the entry will be created and its type will be the type of rhs. If there is a stored entry/type for lhs, its new type will be the LUB between the previous type and the type of rhs. - Parameters:
- field- the field whose type will be refined. Must be either a FieldAccessNode or a LocalVariableNode whose element kind is FIELD.
- rhs- the expression being assigned to the field
 
- 
updateFieldFromTypevoid updateFieldFromType(Tree lhsTree, Element element, String fieldName, AnnotatedTypeMirror rhsATM) Updates the type offieldbased on an assignment whose right-hand side has typerhsATM. See more details atupdateFromFieldAssignment(org.checkerframework.dataflow.cfg.node.Node, org.checkerframework.dataflow.cfg.node.Node).- Parameters:
- lhsTree- the tree for the field whose type will be refined
- element- the element for the field whose type will be refined
- fieldName- the name of the field whose type will be refined
- rhsATM- the type of the expression being assigned to the field
 
- 
updateFromReturnvoid updateFromReturn(ReturnNode retNode, com.sun.tools.javac.code.Symbol.ClassSymbol classSymbol, MethodTree methodTree, Map<AnnotatedTypeMirror.AnnotatedDeclaredType, ExecutableElement> overriddenMethods) Updates the return type of the methodmethodTreebased onreturnedExpression. Also updates the return types of any methods that this method overrides that are available as source code.If there is no stored annotated return type for the method methodTree, then the type of the return expression will be added to the return type of that method. If there is a stored annotated return type for the method methodTree, its new type will be the LUB between the previous type and the type of the return expression. - Parameters:
- retNode- the node that contains the expression returned
- classSymbol- the symbol of the class that contains the method
- methodTree- the tree of the method whose return type may be updated
- overriddenMethods- the methods that the given method return overrides, indexed by the annotated type of the superclass in which each method is defined
 
- 
updateContractsvoid updateContracts(Analysis.BeforeOrAfter preOrPost, ExecutableElement methodElement, CFAbstractStore<?, ?> store) Updates the preconditions or postconditions of the current method, from a store.- Parameters:
- methodElement- the method or constructor whose preconditions or postconditions to update
- preOrPost- whether to update preconditions or postconditions
- store- the store at the method's entry or normal exit, for reading types of expressions
 
- 
addMethodDeclarationAnnotationUpdates a method to add a declaration annotation.- Parameters:
- methodElt- the method to annotate
- anno- the declaration annotation to add to the method
 
- 
addFieldDeclarationAnnotationUpdates a field to add a declaration annotation.- Parameters:
- fieldElt- the field to annotate
- anno- the declaration annotation to add to the field
 
- 
addDeclarationAnnotationToFormalParametervoid addDeclarationAnnotationToFormalParameter(ExecutableElement methodElt, int index, AnnotationMirror anno) Adds a declaration annotation to a formal parameter.- Parameters:
- methodElt- the method whose formal parameter will be annotated
- index- the index of the parameter (0-indexed)
- anno- the annotation to add
 
- 
addClassDeclarationAnnotationAdds an annotation to a class declaration.- Parameters:
- classElt- the class declaration to annotate
- anno- the annotation to add
 
- 
writeResultsToFileWrites the inferred results to a file. Ideally, it should be called at the end of the type-checking process. In practice, it is called after each class, because we don't know which class will be the last one in the type-checking process.- Parameters:
- format- the file format in which to write the results
- checker- the checker from which this method is called, for naming stub files
 
- 
preprocessClassTreePerforms any preparation required for inference on Elements of a class. Should be called on each toplevel class declaration in a compilation unit before processing it.- Parameters:
- classTree- the class to preprocess
 
 
-