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"})
@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 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
FieldsModifier and TypeFieldDescriptionstatic final booleanDefault forLINT_NOINITFORMONOTONICNONNULL.static final booleanDefault forLINT_PERMITCLEARPROPERTY.static final booleanDefault forLINT_REDUNDANTNULLCOMPARISON.static final booleanDefault forLINT_TRUSTARRAYLENZERO.static final StringShould we be strict about initialization ofMonotonicNonNullvariables?static final StringIf true, client code may clear system properties.static final StringWarn about redundant comparisons of an expression withnull, if the expression is known to be non-null.static final StringShould 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, visitorFields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether 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, messageKeyMatchesMethods 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, warnUnneededSuppressionsMethods 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, 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
-
LINT_NOINITFORMONOTONICNONNULL
Should we be strict about initialization ofMonotonicNonNullvariables?- 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.getPropertyare 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:InitializationCheckerWhether to check primitives for initialization.- Specified by:
checkPrimitivesin classInitializationChecker- Returns:
- whether to check primitives for initialization
-
getTargetCheckerClass
Description copied from class:InitializationCheckerThe checker for the target type system for which to check initialization.- Specified by:
getTargetCheckerClassin classInitializationChecker- Returns:
- the checker for the target type system.
-