Class ResourceLeakChecker
java.lang.Object
javax.annotation.processing.AbstractProcessor
org.checkerframework.javacutil.AbstractTypeProcessor
org.checkerframework.framework.source.SourceChecker
org.checkerframework.framework.source.AggregateChecker
org.checkerframework.checker.resourceleak.ResourceLeakChecker
- All Implemented Interfaces:
Processor,OptionConfiguration
@SupportedOptions({"permitStaticOwning","permitInitializationLeak","countMustCall","resourceLeakIgnoredExceptions","noCreatesMustCallFor","noLightweightOwnership","noResourceAliases","enableWpiForRlc","enableReturnsReceiverForRlc"})
public class ResourceLeakChecker
extends AggregateChecker
The entry point for the Resource Leak Checker. This checker only counts the number of
MustCall annotations. This checker calls the RLCCalledMethodsChecker as a direct subchecker, which then in turn calls the MustCallChecker as a subchecker, and afterwards this checker traverses the CFG to check whether
all MustCall obligations are fulfilled.
The checker hierarchy is: this "empty" RLC → RLCCalledMethodsChecker → MustCallChecker
The MustCallChecker is a subchecker of the RLCCm checker (instead of a sibling), since we want them to operate on the same CFG (so we can get both a CM and MC store for a given CFG block), which only works if one of them is a subchecker of the other.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.source.SourceChecker
SourceChecker.CheckerMessage -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCommand-line option for counting how many must-call obligations were checked by the Resource Leak Checker, and emitting the number after processing all files.static final StringThe Returns Receiver Checker is disabled by default for the Resource Leak Checker, as it adds significant overhead and typically provides little benefit.static final StringOrdinarily, when the -Ainfer flag is used, whole-program inference is run for every checker and sub-checker.Fields inherited from class org.checkerframework.framework.source.SourceChecker
activeOptions, currentRoot, DETAILS_SEPARATOR, elements, elementsWithSuppressedWarnings, immediateSubcheckers, javacErrored, messager, messagesProperties, messageStore, MSGS_FILE, OPTION_SEPARATOR, parentChecker, subcheckers, supportedOptions, SUPPRESS_ALL_PREFIX, suppressWarningsPrefixesOfSubcheckers, treePathCacher, trees, types, upstreamCheckerNames, useAllcheckersPrefix, visitorFields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Set<Class<? extends SourceChecker>> Returns the list of independent subcheckers to be run together.Returns a modifiable set of lower-case strings that are prefixes for SuppressWarnings strings.voidreportError(@Nullable Object source, @CompilerMessageKey String messageKey, Object... args) Reports an error.voidA method to be called once all the classes are processed.Methods inherited from class org.checkerframework.framework.source.AggregateChecker
createSourceVisitor, getImmediateSubcheckerClassesMethods inherited from class org.checkerframework.framework.source.SourceChecker
createSupportedLintOptions, expandCFOptions, fullMessageOf, getAnnotationProvider, getBooleanOption, getBooleanOption, getElementUtils, getExtraStubFiles, getLintOption, getLintOption, getMessagesProperties, getOption, getOption, getOptionConfiguration, getOptions, getOptionsNoSubcheckers, getParentChecker, getPathToCompilationUnit, getProcessingEnvironment, getProperties, getRelatedClassName, getStandardSuppressWarningsPrefixes, getStringsOption, getStringsOption, getSubchecker, getSubCheckerIndex, getSubcheckers, getSupportedAnnotationTypes, getSupportedLintOptions, getSupportedOptions, getSupportedSourceVersion, getSuppressWarningsPrefixesOfSubcheckers, getTreePathCacher, getTreeUtils, getTypeUtils, getUpstreamCheckerNames, getVisitor, hasOption, hasOptionNoSubcheckers, init, initChecker, instantiateSubcheckers, message, message, messageKeyMatches, printOrStoreMessage, printOrStoreMessage, printStats, printStoredMessages, processErrorMessageArg, report, reportOnce, reportWarning, setLintOption, setParentChecker, setRoot, shouldAddShutdownHook, shouldResolveReflection, shouldSkipDefs, shouldSkipDefs, shouldSkipDefs, shouldSkipFiles, shouldSkipUses, shouldSkipUses, shouldSuppressWarnings, shouldSuppressWarnings, shouldSuppressWarnings, shutdownHook, typeProcess, typeProcessingStart, useConservativeDefault, warnUnneededSuppressions, warnUnneededSuppressionsMethods inherited from class org.checkerframework.javacutil.AbstractTypeProcessor
getCompilerLog, processMethods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.checkerframework.framework.util.OptionConfiguration
getStringsOption, getStringsOption
-
Field Details
-
COUNT_MUST_CALL
Command-line option for counting how many must-call obligations were checked by the Resource Leak Checker, and emitting the number after processing all files. Used for generating tables for a research paper. Not of interest to most users.- See Also:
-
ENABLE_WPI_FOR_RLC
Ordinarily, when the -Ainfer flag is used, whole-program inference is run for every checker and sub-checker. However, the Resource Leak Checker is different. The -Ainfer flag enables the RLC's own (non-WPI) inference mechanism (MustCallInference). To use WPI in addition to this mechanism for its sub-checkers, use the -AenableWpiForRlc flag, which is intended only for testing and experiments.- See Also:
-
ENABLE_RETURNS_RECEIVER
The Returns Receiver Checker is disabled by default for the Resource Leak Checker, as it adds significant overhead and typically provides little benefit. To enable it, use the -AenableReturnsReceiverForRlc flag.- See Also:
-
-
Constructor Details
-
ResourceLeakChecker
public ResourceLeakChecker()Creates a ResourceLeakChecker.
-
-
Method Details
-
getSupportedCheckers
Description copied from class:AggregateCheckerReturns the list of independent subcheckers to be run together. An aggregate checker overrides this method to indicate its immediate subcheckers.- Specified by:
getSupportedCheckersin classAggregateChecker- Returns:
- the list of immediate subcheckers checkers to be run
-
reportError
public void reportError(@Nullable Object source, @CompilerMessageKey String messageKey, Object... args) Description copied from class:SourceCheckerReports an error. By default, prints it to the screen via the compiler's internal messager.- Overrides:
reportErrorin classSourceChecker- Parameters:
source- the source position information; may be an Element, a Tree, or nullmessageKey- the message keyargs- arguments for interpolation in the string corresponding to the given message key
-
typeProcessingOver
public void typeProcessingOver()Description copied from class:AbstractTypeProcessorA method to be called once all the classes are processed.Subclasses may override this method to do any aggregate analysis (e.g. generate report, persistence) or resource deallocation.
Method
AbstractTypeProcessor.getCompilerLog()can be used to access the number of compiler errors.- Overrides:
typeProcessingOverin classSourceChecker
-
getSuppressWarningsPrefixes
Description copied from class:SourceCheckerReturns a modifiable set of lower-case strings that are prefixes for SuppressWarnings strings.The collection must not be empty and must not contain only
SourceChecker.SUPPRESS_ALL_PREFIX.- Overrides:
getSuppressWarningsPrefixesin classSourceChecker- Returns:
- non-empty modifiable set of lower-case prefixes for SuppressWarnings strings
-