Class MustCallInference


public class MustCallInference extends Object
This class implements the annotation inference algorithm for the Resource Leak Checker. It infers annotations such as @Owning on owning fields and parameters, @NotOwning on return types, @EnsuresCalledMethods on methods, @MustCallAlias on parameters and return types, and @InheritableMustCall on class declarations.

Each instance of this class corresponds to a single control flow graph (CFG), typically representing a method. The entry method of this class is runMustCallInference(ResourceLeakAnnotatedTypeFactory, ControlFlowGraph, MustCallConsistencyAnalyzer), invoked from the ResourceLeakAnnotatedTypeFactory.postAnalyze(org.checkerframework.dataflow.cfg.ControlFlowGraph) method when Whole Program Inference is enabled.

The algorithm determines if the @MustCall obligation of a field is satisfied along some path leading to the regular exit point of the method. If the obligation is satisfied, the algorithm adds an @Owning annotation on the field and an @EnsuresCalledMethods annotation on the method being analyzed. Additionally, if the method being analyzed satisfies the must-call obligation of all the enclosed owning fields, the algorithm adds a @InheritableMustCall annotation on the enclosing class.

Note: This class makes the assumption that the must-call set has only one element. Must-call sets with more than one element may be supported in the future.

See ResourceLeakChecker.ENABLE_WPI_FOR_RLC for an explanation of the meaning of the flags -Ainfer and -AenableWpiForRlc.

See Also: