Class NullnessChecker
java.lang.Object
javax.annotation.processing.AbstractProcessor
org.checkerframework.javacutil.AbstractTypeProcessor
org.checkerframework.framework.source.SourceChecker
org.checkerframework.common.basetype.BaseTypeChecker
org.checkerframework.checker.initialization.InitializationChecker
org.checkerframework.checker.nullness.NullnessChecker
- All Implemented Interfaces:
Processor
,OptionConfiguration
@SupportedLintOptions({"noInitForMonotonicNonNull","redundantNullComparison","soundArrayCreationNullness","forbidnonnullarraycomponents","trustArrayLenZero","permitClearProperty"})
@SupportedOptions({"assumeKeyFor","assumeInitialized","jspecifyNullMarkedAlias","conservativeArgumentNullnessAfterInvocation"})
public class NullnessChecker
extends InitializationChecker
An implementation of the nullness type-system, parameterized by an initialization type-system for
safe initialization. It uses freedom-before-commitment, augmented by type frames (which are
crucial to obtain acceptable precision), as its initialization type system.
This checker uses the NullnessNoInitSubchecker
to check for nullness and extends the
InitializationChecker
to also check that all non-null fields are properly initialized.
You can use the following SuppressWarnings
prefixes with this checker:
@SuppressWarnings("nullness")
suppresses warnings for both nullness and initialization annotations@SuppressWarnings("initialization")
suppresses warnings for initialization annotations only@SuppressWarnings("nullnessnoinit")
suppresses warnings for nullness annotations only
- See Also:
- See the Checker Framework Manual:
- Nullness Checker
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Default forLINT_NOINITFORMONOTONICNONNULL
.static final boolean
Default forLINT_PERMITCLEARPROPERTY
.static final boolean
Default forLINT_REDUNDANTNULLCOMPARISON
.static final boolean
Default forLINT_TRUSTARRAYLENZERO
.static final String
Should we be strict about initialization ofMonotonicNonNull
variables?static final String
If true, client code may clear system properties.static final String
Warn about redundant comparisons of an expression withnull
, if the expression is known to be non-null.static final String
Should the Nullness Checker unsoundly trust@ArrayLen(0)
annotations to improve handling ofCollection.toArray()
byCollectionToArrayHeuristics
?Fields inherited from class org.checkerframework.framework.source.SourceChecker
currentRoot, DETAILS_SEPARATOR, elements, elementsWithSuppressedWarnings, errsOnLastExit, javacErrored, messager, messagesProperties, MSGS_FILE, OPTION_SEPARATOR, parentChecker, SUPPRESS_ALL_MESSAGE_KEY, SUPPRESS_ALL_PREFIX, treePathCacher, trees, types, UNNEEDED_SUPPRESSION_KEY, upstreamCheckerNames, useAllcheckersPrefix, visitor
Fields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether to check primitives for initialization.Class
<? extends BaseTypeChecker> The checker for the target type system for which to check initialization.Methods inherited from class org.checkerframework.checker.initialization.InitializationChecker
createSourceVisitor, getAllFields, getImmediateSubcheckerClasses, getSuppressWarningsPrefixes, getTypeFactory, messageKeyMatches
Methods inherited from class org.checkerframework.common.basetype.BaseTypeChecker
createSourceVisitorPublic, getAnnotationProvider, getExtraStubFiles, getOptions, getOptionsNoSubcheckers, getRelatedClassName, getSubchecker, getSubcheckers, getSupportedLintOptions, getSupportedOptions, getSuppressWarningsPrefixesOfSubcheckers, getTypeFactoryOfSubcheckerOrNull, getUltimateParentChecker, getVisitor, hasOptionNoSubcheckers, initChecker, invokeConstructorFor, printOrStoreMessage, processErrorMessageArg, setRoot, shouldAddShutdownHook, shouldResolveReflection, shutdownHook, typeProcess, typeProcessingOver, warnUnneededSuppressions
Methods inherited from class org.checkerframework.framework.source.SourceChecker
addOptions, createSupportedLintOptions, expandCFOptions, fullMessageOf, getBooleanOption, getBooleanOption, getElementUtils, getLintOption, getLintOption, getMessagesProperties, getOption, getOption, getOptionConfiguration, getParentChecker, getPathToCompilationUnit, getProcessingEnvironment, getProperties, getStandardSuppressWarningsPrefixes, getStringsOption, getStringsOption, getSupportedAnnotationTypes, getSupportedSourceVersion, getTreePathCacher, getTreeUtils, getTypeUtils, getUpstreamCheckerNames, getWarningMessagePrefix, hasOption, init, message, message, printOrStoreMessage, printStats, report, reportError, reportWarning, setLintOption, setParentChecker, setProcessingEnvironment, setSupportedLintOptions, shouldSkipDefs, shouldSkipDefs, shouldSkipUses, shouldSkipUses, shouldSuppressWarnings, shouldSuppressWarnings, shouldSuppressWarnings, typeProcessingStart, useConservativeDefault, warnUnneededSuppressions
Methods inherited from class org.checkerframework.javacutil.AbstractTypeProcessor
getCompilerLog, process
Methods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, isInitialized
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.checkerframework.framework.util.OptionConfiguration
getStringsOption, getStringsOption
-
Field Details
-
LINT_NOINITFORMONOTONICNONNULL
Should we be strict about initialization ofMonotonicNonNull
variables?- See Also:
-
LINT_DEFAULT_NOINITFORMONOTONICNONNULL
public static final boolean LINT_DEFAULT_NOINITFORMONOTONICNONNULLDefault forLINT_NOINITFORMONOTONICNONNULL
.- See Also:
-
LINT_REDUNDANTNULLCOMPARISON
Warn about redundant comparisons of an expression withnull
, if the expression is known to be non-null.- See Also:
-
LINT_DEFAULT_REDUNDANTNULLCOMPARISON
public static final boolean LINT_DEFAULT_REDUNDANTNULLCOMPARISONDefault forLINT_REDUNDANTNULLCOMPARISON
.- See Also:
-
LINT_TRUSTARRAYLENZERO
Should the Nullness Checker unsoundly trust@ArrayLen(0)
annotations to improve handling ofCollection.toArray()
byCollectionToArrayHeuristics
?- See Also:
-
LINT_DEFAULT_TRUSTARRAYLENZERO
public static final boolean LINT_DEFAULT_TRUSTARRAYLENZERODefault forLINT_TRUSTARRAYLENZERO
.- See Also:
-
LINT_PERMITCLEARPROPERTY
If true, client code may clear system properties. If false (the default), some calls toSystem.getProperty
are refined to return @NonNull.- See Also:
-
LINT_DEFAULT_PERMITCLEARPROPERTY
public static final boolean LINT_DEFAULT_PERMITCLEARPROPERTYDefault forLINT_PERMITCLEARPROPERTY
.- See Also:
-
-
Constructor Details
-
NullnessChecker
public NullnessChecker()Default constructor for NullnessChecker.
-
-
Method Details
-
checkPrimitives
public boolean checkPrimitives()Description copied from class:InitializationChecker
Whether to check primitives for initialization.- Specified by:
checkPrimitives
in classInitializationChecker
- Returns:
- whether to check primitives for initialization
-
getTargetCheckerClass
Description copied from class:InitializationChecker
The checker for the target type system for which to check initialization.- Specified by:
getTargetCheckerClass
in classInitializationChecker
- Returns:
- the checker for the target type system.
-