Class InitializationFieldAccessSubchecker
- All Implemented Interfaces:
Processor,OptionConfiguration
This checker does not actually do any type checking. It exists to provide its parent checker
(the InitializationChecker.getTargetCheckerClass()) with declared initialization
qualifiers via the InitializationFieldAccessTreeAnnotator.
Additionally, this checker performs the flow-sensitive type refinement for the fbc type system, which is necessary to avoid reporting follow-up errors related to initialization (see the AssignmentDuringInitialization test case). To avoid performing the same type refinement twice, the InitializationChecker performs no refinement, instead reusing the results from this checker.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.source.SourceChecker
SourceChecker.CheckerMessage -
Field Summary
Fields inherited from class org.checkerframework.framework.source.SourceChecker
currentRoot, DETAILS_SEPARATOR, elements, messager, MSGS_FILE, OPTION_SEPARATOR, parentChecker, SUPPRESS_ALL_MESSAGE_KEY, SUPPRESS_ALL_PREFIX, trees, types, UNNEEDED_SUPPRESSION_KEY, upstreamCheckerNames, useAllcheckersPrefix, visitorFields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for InitializationFieldAccessSubchecker. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddOptionsForMode(String mode, Map<String, String> activeOptions) Adds toactiveOptionsthe options thatmodeenables for this checker.Also handleAnnotatedForannotations for theInitializationChecker.voidreportError(@Nullable Object source, @CompilerMessageKey String messageKey, Object... args) Reports an error.voidreportWarning(@Nullable Object source, @CompilerMessageKey String messageKey, Object... args) Reports a warning.Methods inherited from class org.checkerframework.common.basetype.BaseTypeChecker
createSourceVisitor, createSourceVisitorPublic, getAnnotationProvider, getTypeFactory, getTypeFactoryOfSubcheckerOrNull, getUltimateParentChecker, getVisitor, invokeConstructorFor, isElementAnnotatedForThisCheckerOrUpstreamChecker, processErrorMessageArg, shouldAddShutdownHook, shutdownHookMethods inherited from class org.checkerframework.framework.source.SourceChecker
createMessagesProperties, createRelevantJavaTypes, createSupportedLintOptions, createSupportedModes, expandCFOptions, expandCFOptions, fullMessageOf, getAssumeAssertions, getBooleanOption, getBooleanOption, getClassHierarchy, getElementUtils, getErrorCount, getExtraStubFiles, getImmediateSubcheckerClasses, getLintOption, getLintOption, getOption, getOption, getOptionConfiguration, getOptions, getOptionsNoSubcheckers, getParentChecker, getPathToCompilationUnit, getProcessingEnvironment, getProperties, getRelatedClassName, getRelevantJavaTypes, getStandardSuppressWarningsPrefixes, getStringsOption, getStringsOption, getStubFiles, getSubchecker, getSubCheckerIndex, getSubcheckers, getSupportedAnnotationTypes, getSupportedLintOptions, getSupportedModes, getSupportedOptions, getSupportedSourceVersion, getSuppressWarningsPrefixes, getSuppressWarningsPrefixesOfSubcheckers, getTreePathCacher, getTreeUtils, getTypeUtils, getWarningMessagePrefix, handleProcessingError, hasOption, hasOptionNoSubcheckers, init, initChecker, instantiateSubcheckers, message, message, messageKeyMatches, packageProcess, printStats, printStoredMessages, report, setDiagnosticSink, setHostOptions, setLintOption, setParentChecker, setRoot, shouldResolveReflection, shouldSkipDefs, shouldSkipDefs, shouldSkipDefs, shouldSkipDefs, shouldSkipFiles, shouldSkipUses, shouldSkipUses, shouldSuppressWarnings, shouldSuppressWarnings, shouldSuppressWarnings, suppressWarningsString, typeProcess, typeProcessingOver, typeProcessingStart, useConservativeDefault, usePermissiveDefault, warnUnneededSuppressions, warnUnneededSuppressionsMethods inherited from class org.checkerframework.javacutil.AbstractTypeProcessor
getCompilerLog, isExternallyDriven, packageProcessExternally, process, setExternallyDriven, typeProcessExternally, typeProcessingOverExternallyMethods 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
-
Constructor Details
-
InitializationFieldAccessSubchecker
public InitializationFieldAccessSubchecker()Default constructor for InitializationFieldAccessSubchecker.
-
-
Method Details
-
addOptionsForMode
Description copied from class:SourceCheckerAdds toactiveOptionsthe options thatmodeenables for this checker. The default implementation adds none; a checker that declares modes withSupportedModesoverrides this, callssuper, and ignores a mode it does not recognize (another checker in the same run may define it).Use
Map.putIfAbsent(K, V):activeOptionsalready holds the options written on the command line, which take precedence over the mode.- Overrides:
addOptionsForModein classSourceChecker- Parameters:
mode- the value of the-AmodeoptionactiveOptions- the active options, to which mode options are added
-
getUpstreamCheckerNames
Also handleAnnotatedForannotations for theInitializationChecker. SeeInitializationChecker.getUpstreamCheckerNames()and the two implementations should be kept in sync.- Overrides:
getUpstreamCheckerNamesin classSourceChecker- Returns:
- a list containing this checker name and all checkers it is a part of (that is, checkers that called it)
- See Also:
-
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.Prefer a Tree: pass an Element only for a declaration that has none, such as one read from bytecode. Under a host that collects diagnostics, such as the Error Prone plugin, an Element declared in the current compilation unit is reported on its declaration; any other Element is reported directly to javac, bypassing the host's severity and suppression.
- Overrides:
reportErrorin classSourceChecker- Parameters:
source- the source position information; may be an Element or a Tree. Null means the error has no source position -- for example, it is issued while the checker is initializing, before any source file is processed -- and is reported against the compilation as a whole.messageKey- the message keyargs- arguments for interpolation in the string corresponding to the given message key
-
reportWarning
public void reportWarning(@Nullable Object source, @CompilerMessageKey String messageKey, Object... args) Description copied from class:SourceCheckerReports a warning. By default, prints it to the screen via the compiler's internal messager.Prefer a Tree: pass an Element only for a declaration that has none, such as one read from bytecode. Under a host that collects diagnostics, such as the Error Prone plugin, an Element declared in the current compilation unit is reported on its declaration; any other Element is reported directly to javac, bypassing the host's severity and suppression.
- Overrides:
reportWarningin classSourceChecker- Parameters:
source- the source position information; may be an Element or a Tree. Null means the warning has no source position -- for example, it is issued while the checker is initializing, before any source file is processed. Such a warning cannot be suppressed by a@SuppressWarningsannotation, because there is no declaration to write one on; only the-AsuppressWarningscommand-line option suppresses it.messageKey- the message keyargs- arguments for interpolation in the string corresponding to the given message key
-