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:
javax.annotation.processing.Processor
,OptionConfiguration
@SupportedLintOptions({"noInitForMonotonicNonNull","redundantNullComparison","soundArrayCreationNullness","forbidnonnullarraycomponents","trustArrayLenZero","permitClearProperty"}) @SupportedOptions({"assumeKeyFor","assumeInitialized","jspecifyNullMarkedAlias","conservativeArgumentNullnessAfterInvocation"}) @StubFiles("junit-assertions.astub") 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 theInitializationChecker
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:
KeyForSubchecker
,InitializationChecker
,NullnessNoInitSubchecker
- See the Checker Framework Manual:
- Nullness Checker
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
LINT_DEFAULT_NOINITFORMONOTONICNONNULL
Default forLINT_NOINITFORMONOTONICNONNULL
.static boolean
LINT_DEFAULT_PERMITCLEARPROPERTY
Default forLINT_PERMITCLEARPROPERTY
.static boolean
LINT_DEFAULT_REDUNDANTNULLCOMPARISON
Default forLINT_REDUNDANTNULLCOMPARISON
.static boolean
LINT_DEFAULT_TRUSTARRAYLENZERO
Default forLINT_TRUSTARRAYLENZERO
.static java.lang.String
LINT_NOINITFORMONOTONICNONNULL
Should we be strict about initialization ofMonotonicNonNull
variables?static java.lang.String
LINT_PERMITCLEARPROPERTY
If true, client code may clear system properties.static java.lang.String
LINT_REDUNDANTNULLCOMPARISON
Warn about redundant comparisons of an expression withnull
, if the expression is known to be non-null.static java.lang.String
LINT_TRUSTARRAYLENZERO
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
-
-
Constructor Summary
Constructors Constructor Description NullnessChecker()
Default constructor for NullnessChecker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkPrimitives()
Whether to check primitives for initialization.java.lang.Class<? extends BaseTypeChecker>
getTargetCheckerClass()
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 Detail
-
LINT_NOINITFORMONOTONICNONNULL
public static final java.lang.String LINT_NOINITFORMONOTONICNONNULL
Should we be strict about initialization ofMonotonicNonNull
variables?- See Also:
- Constant Field Values
-
LINT_DEFAULT_NOINITFORMONOTONICNONNULL
public static final boolean LINT_DEFAULT_NOINITFORMONOTONICNONNULL
Default forLINT_NOINITFORMONOTONICNONNULL
.- See Also:
- Constant Field Values
-
LINT_REDUNDANTNULLCOMPARISON
public static final java.lang.String LINT_REDUNDANTNULLCOMPARISON
Warn about redundant comparisons of an expression withnull
, if the expression is known to be non-null.- See Also:
- Constant Field Values
-
LINT_DEFAULT_REDUNDANTNULLCOMPARISON
public static final boolean LINT_DEFAULT_REDUNDANTNULLCOMPARISON
Default forLINT_REDUNDANTNULLCOMPARISON
.- See Also:
- Constant Field Values
-
LINT_TRUSTARRAYLENZERO
public static final java.lang.String LINT_TRUSTARRAYLENZERO
Should the Nullness Checker unsoundly trust@ArrayLen(0)
annotations to improve handling ofCollection.toArray()
byCollectionToArrayHeuristics
?- See Also:
- Constant Field Values
-
LINT_DEFAULT_TRUSTARRAYLENZERO
public static final boolean LINT_DEFAULT_TRUSTARRAYLENZERO
Default forLINT_TRUSTARRAYLENZERO
.- See Also:
- Constant Field Values
-
LINT_PERMITCLEARPROPERTY
public static final java.lang.String 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:
- Constant Field Values
-
LINT_DEFAULT_PERMITCLEARPROPERTY
public static final boolean LINT_DEFAULT_PERMITCLEARPROPERTY
Default forLINT_PERMITCLEARPROPERTY
.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public java.lang.Class<? extends BaseTypeChecker> 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.
-
-