APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.code

public Class Lint

extends Object
Class Inheritance
Imports
java.util.Arrays, .Collections, .EnumSet, .LinkedHashMap, .List, .Optional, .SequencedMap, .SequencedSet, .Set, java.util.stream.Stream, com.sun.tools.javac.main.Option, com.sun.tools.javac.util.Assert, .Context, .JCDiagnostic, .Log, .Names, .Options

A class for handling -Xlint suboptions and @SuppressWarnings.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Lint.LintCategory

Categories of warnings that can be generated by the compiler.

Field Summary

Modifier and TypeField and Description
private final Context
protected static final Context.Key<Lint>
lintKey

The context key for the root Lint object.

private final Log
private Names
private final Options
private EnumSet<Lint.LintCategory>
private Symtab
private EnumSet<Lint.LintCategory>
private boolean

Constructor Summary

AccessConstructor and Description
protected
Lint(Context context)

protected
Lint(Lint other)

Method Summary

Modifier and TypeMethod and Description
public Lint

Returns:

lint instance with new warning suppressions applied, or this instance if none
augment
(Symbol
symbol
sym
)

Obtain an instance with additional warning supression applied from any

private EnumSet<Lint.LintCategory>
private void
private void
public static Lint
instance(Context context)

Get the root Lint instance.

public static boolean
public boolean
isEnabled(Lint.LintCategory lc)

Checks if a warning category is enabled.

public boolean
isSuppressed(Lint.LintCategory lc)

Check if a warning category has been specifically suppressed by means of @SuppressWarnings.

public boolean
shouldEmit(JCDiagnostic diag)

Determine if the given diagnostic should be emitted given the state of this instance.

public EnumSet<Lint.LintCategory>

Returns:

new warning suppressions applied to sym
suppressionsFrom
(Symbol
symbol corresponding to a possibly-annotated declaration
symbol
)

Obtain the set of recognized lint warning categories suppressed at the given symbol's declaration.

private EnumSet<Lint.LintCategory>
private EnumSet<Lint.LintCategory>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

contextback to summary
private final Context context
lintKeyback to summary
protected static final Context.Key<Lint> lintKey

The context key for the root Lint object.

logback to summary
private final Log log
namesback to summary
private Names names
optionsback to summary
private final Options options
suppressedValuesback to summary
private EnumSet<Lint.LintCategory> suppressedValues
symsback to summary
private Symtab syms
valuesback to summary
private EnumSet<Lint.LintCategory> values
withinDeprecatedback to summary
private boolean withinDeprecated

Constructor Detail

Lintback to summary
protected Lint(Context context)
Annotations
@SuppressWarnings:this-escape
Lintback to summary
protected Lint(Lint other)

Method Detail

augmentback to summary
public Lint augment(Symbol sym)

Obtain an instance with additional warning supression applied from any

Parameters
sym:Symbol

symbol

Returns:Lint

lint instance with new warning suppressions applied, or this instance if none

getDefaultsback to summary
private EnumSet<Lint.LintCategory> getDefaults()
initializeRootIfNeededback to summary
private void initializeRootIfNeeded()
initializeSymbolsIfNeededback to summary
private void initializeSymbolsIfNeeded()
instanceback to summary
public static Lint instance(Context context)

Get the root Lint instance.

isDeprecatedDeclarationback to summary
public static boolean isDeprecatedDeclaration(Symbol sym)
isEnabledback to summary
public boolean isEnabled(Lint.LintCategory lc)

Checks if a warning category is enabled. A warning category may be enabled on the command line, or by default, and can be temporarily disabled with the SuppressWarnings annotation.

isSuppressedback to summary
public boolean isSuppressed(Lint.LintCategory lc)

Check if a warning category has been specifically suppressed by means of @SuppressWarnings.

Always returns false for categories that are not suppressible by the annotation, even if they (uselessly) happen to appear in one.

shouldEmitback to summary
public boolean shouldEmit(JCDiagnostic diag)

Determine if the given diagnostic should be emitted given the state of this instance.

suppressionsFromback to summary
public EnumSet<Lint.LintCategory> suppressionsFrom(Symbol symbol)

Obtain the set of recognized lint warning categories suppressed at the given symbol's declaration.

This set can be non-empty only if the symbol is annotated with @SuppressWarnings, and only categories for which annotationSuppression is true are included.

Parameters
symbol:Symbol

symbol corresponding to a possibly-annotated declaration

Returns:EnumSet<Lint.LintCategory>

new warning suppressions applied to sym

suppressionsFromback to summary
private EnumSet<Lint.LintCategory> suppressionsFrom(Stream<Attribute.Compound> attributes)
suppressionsFromback to summary
private EnumSet<Lint.LintCategory> suppressionsFrom(Attribute.Compound suppressWarnings)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
com.sun.tools.javac.code back to summary

public final Enum Lint.LintCategory

extends Enum<Lint.LintCategory>
Class Inheritance

Categories of warnings that can be generated by the compiler. Each lint category has a logical name (a string), which is the string used e.g. in a SuppressWarning annotation. To ensure automation, the enum field name for a lint category string C should be obtained by:
  1. capitalize all the letters in C, and
  2. replacing any occurrence of - with _
For instance, the lint category string dangling-doc-comments corresponds to the enum field DANGLING_DOC_COMMENTS.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
public final boolean
annotationSuppression

Does this category support being suppressed by the @SuppressWarnings annotation?

public static final Lint.LintCategory
AUXILIARYCLASS

Warn when code refers to a auxiliary class that is hidden in a source file (ie source file name is different from the class name, and the type is not properly nested) and the referring code is not located in the same source file.

public static final Lint.LintCategory
CAST

Warn about use of unnecessary casts.

public static final Lint.LintCategory
CLASSFILE

Warn about issues related to classfile contents.

public static final Lint.LintCategory
DANGLING_DOC_COMMENTS

Warn about "dangling" documentation comments, not attached to any declaration.

public static final Lint.LintCategory
DEP_ANN

Warn about items which are documented with an @deprecated JavaDoc comment, but which do not have @Deprecated annotation.

public static final Lint.LintCategory
DEPRECATION

Warn about use of deprecated items.

public static final Lint.LintCategory
DIVZERO

Warn about division by constant integer 0.

public static final Lint.LintCategory
EMPTY

Warn about empty statement after if.

public final boolean
enabledByDefault

Is this category included in the default set of enabled lint categories?

public static final Lint.LintCategory
EXPORTS

Warn about issues regarding module exports.

public static final Lint.LintCategory
FALLTHROUGH

Warn about falling through from one case of a switch statement to the next.

public static final Lint.LintCategory
FINALLY

Warn about finally clauses that do not terminate normally.

public static final Lint.LintCategory
IDENTITY

Warn about uses of @ValueBased classes where an identity class is expected.

public static final Lint.LintCategory
INCUBATING

Warn about use of incubating modules.

private static final SequencedMap<String, Lint.LintCategory>
public static final Lint.LintCategory
LOSSY_CONVERSIONS

Warn about compiler possible lossy conversions.

public static final Lint.LintCategory
MISSING_EXPLICIT_CTOR

Warn about compiler generation of a default constructor.

public static final Lint.LintCategory
MODULE

Warn about module system related issues.

public static final Lint.LintCategory
OPENS

Warn about issues regarding module opens.

public final String
option

Get the "canonical" string representing this category in @SuppressAnnotations and -Xlint options.

public final List<String>
optionList

Get a list containing "option" followed by zero or more aliases.

public static final Lint.LintCategory
OPTIONS

Warn about issues relating to use of command line options.

public static final Lint.LintCategory
OUTPUT_FILE_CLASH

Warn when any output file is written to more than once.

public static final Lint.LintCategory
OVERLOADS

Warn about issues regarding method overloads.

public static final Lint.LintCategory
OVERRIDES

Warn about issues regarding method overrides.

public static final Lint.LintCategory
PATH

Warn about invalid path elements on the command line.

public static final Lint.LintCategory
PREVIEW

Warn about use of preview features.

public static final Lint.LintCategory
PROCESSING

Warn about issues regarding annotation processing.

public static final Lint.LintCategory
RAWTYPES

Warn about unchecked operations on raw types.

public static final Lint.LintCategory
REMOVAL

Warn about use of deprecated-for-removal items.

public static final Lint.LintCategory
REQUIRES_AUTOMATIC

Warn about use of automatic modules in the requires clauses.

public static final Lint.LintCategory
REQUIRES_TRANSITIVE_AUTOMATIC

Warn about automatic modules in requires transitive.

public static final Lint.LintCategory
RESTRICTED

Warn about use of restricted methods.

public static final Lint.LintCategory
SERIAL

Warn about Serializable classes that do not provide a serial version ID.

public static final Lint.LintCategory
STATIC

Warn about issues relating to use of statics

public static final Lint.LintCategory
STRICTFP

Warn about unnecessary uses of the strictfp modifier

public static final Lint.LintCategory
TEXT_BLOCKS

Warn about issues relating to use of text blocks

public static final Lint.LintCategory
THIS_ESCAPE

Warn about possible 'this' escapes before subclass instance is fully initialized.

public static final Lint.LintCategory
TRY

Warn about issues relating to use of try blocks (i.e. try-with-resources)

public static final Lint.LintCategory
UNCHECKED

Warn about unchecked operations on raw types.

public static final Lint.LintCategory
VARARGS

Warn about potentially unsafe vararg methods

Constructor Summary

AccessConstructor and Description
private
LintCategory(String option, Lint.LintCategory.Property... properties)

private
LintCategory(List<String> options, Lint.LintCategory.Property... properties)

Method Summary

Modifier and TypeMethod and Description
private static SequencedMap<String, Lint.LintCategory>
public static Optional<Lint.LintCategory>

Returns:

corresponding LintCategory, or empty if none exists
get
(String
lint category option string
option
)

Get the LintCategory having the given command line option.

public static EnumSet<Lint.LintCategory>
public static SequencedSet<String>
options()

Get all lint category option strings and aliases.

public static Lint.LintCategory
public static Lint.LintCategory[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

annotationSuppressionback to summary
public final boolean annotationSuppression

Does this category support being suppressed by the @SuppressWarnings annotation?

AUXILIARYCLASSback to summary
public static final Lint.LintCategory AUXILIARYCLASS

Warn when code refers to a auxiliary class that is hidden in a source file (ie source file name is different from the class name, and the type is not properly nested) and the referring code is not located in the same source file.

CASTback to summary
public static final Lint.LintCategory CAST

Warn about use of unnecessary casts.

CLASSFILEback to summary
public static final Lint.LintCategory CLASSFILE

Warn about issues related to classfile contents.

This category is not supported by @SuppressWarnings.

DANGLING_DOC_COMMENTSback to summary
public static final Lint.LintCategory DANGLING_DOC_COMMENTS

Warn about "dangling" documentation comments, not attached to any declaration.

DEP_ANNback to summary
public static final Lint.LintCategory DEP_ANN

Warn about items which are documented with an @deprecated JavaDoc comment, but which do not have @Deprecated annotation.

DEPRECATIONback to summary
public static final Lint.LintCategory DEPRECATION

Warn about use of deprecated items.

DIVZEROback to summary
public static final Lint.LintCategory DIVZERO

Warn about division by constant integer 0.

EMPTYback to summary
public static final Lint.LintCategory EMPTY

Warn about empty statement after if.

enabledByDefaultback to summary
public final boolean enabledByDefault

Is this category included in the default set of enabled lint categories? Note that for some categories, command line options can alter this at runtime.

EXPORTSback to summary
public static final Lint.LintCategory EXPORTS

Warn about issues regarding module exports.

FALLTHROUGHback to summary
public static final Lint.LintCategory FALLTHROUGH

Warn about falling through from one case of a switch statement to the next.

FINALLYback to summary
public static final Lint.LintCategory FINALLY

Warn about finally clauses that do not terminate normally.

IDENTITYback to summary
public static final Lint.LintCategory IDENTITY

Warn about uses of @ValueBased classes where an identity class is expected.

INCUBATINGback to summary
public static final Lint.LintCategory INCUBATING

Warn about use of incubating modules.

This category is not supported by @SuppressWarnings.

lookupback to summary
private static final SequencedMap<String, Lint.LintCategory> lookup
LOSSY_CONVERSIONSback to summary
public static final Lint.LintCategory LOSSY_CONVERSIONS

Warn about compiler possible lossy conversions.

MISSING_EXPLICIT_CTORback to summary
public static final Lint.LintCategory MISSING_EXPLICIT_CTOR

Warn about compiler generation of a default constructor.

MODULEback to summary
public static final Lint.LintCategory MODULE

Warn about module system related issues.

OPENSback to summary
public static final Lint.LintCategory OPENS

Warn about issues regarding module opens.

optionback to summary
public final String option

Get the "canonical" string representing this category in @SuppressAnnotations and -Xlint options.

optionListback to summary
public final List<String> optionList

Get a list containing "option" followed by zero or more aliases.

OPTIONSback to summary
public static final Lint.LintCategory OPTIONS

Warn about issues relating to use of command line options.

This category is not supported by @SuppressWarnings.

OUTPUT_FILE_CLASHback to summary
public static final Lint.LintCategory OUTPUT_FILE_CLASH

Warn when any output file is written to more than once.

This category is not supported by @SuppressWarnings.

OVERLOADSback to summary
public static final Lint.LintCategory OVERLOADS

Warn about issues regarding method overloads.

OVERRIDESback to summary
public static final Lint.LintCategory OVERRIDES

Warn about issues regarding method overrides.

PATHback to summary
public static final Lint.LintCategory PATH

Warn about invalid path elements on the command line.

This category is not supported by @SuppressWarnings.

PREVIEWback to summary
public static final Lint.LintCategory PREVIEW

Warn about use of preview features.

PROCESSINGback to summary
public static final Lint.LintCategory PROCESSING

Warn about issues regarding annotation processing.

This category is not supported by @SuppressWarnings.

RAWTYPESback to summary
public static final Lint.LintCategory RAWTYPES

Warn about unchecked operations on raw types.

REMOVALback to summary
public static final Lint.LintCategory REMOVAL

Warn about use of deprecated-for-removal items.

REQUIRES_AUTOMATICback to summary
public static final Lint.LintCategory REQUIRES_AUTOMATIC

Warn about use of automatic modules in the requires clauses.

REQUIRES_TRANSITIVE_AUTOMATICback to summary
public static final Lint.LintCategory REQUIRES_TRANSITIVE_AUTOMATIC

Warn about automatic modules in requires transitive.

RESTRICTEDback to summary
public static final Lint.LintCategory RESTRICTED

Warn about use of restricted methods.

SERIALback to summary
public static final Lint.LintCategory SERIAL

Warn about Serializable classes that do not provide a serial version ID.

STATICback to summary
public static final Lint.LintCategory STATIC

Warn about issues relating to use of statics

STRICTFPback to summary
public static final Lint.LintCategory STRICTFP

Warn about unnecessary uses of the strictfp modifier

TEXT_BLOCKSback to summary
public static final Lint.LintCategory TEXT_BLOCKS

Warn about issues relating to use of text blocks

THIS_ESCAPEback to summary
public static final Lint.LintCategory THIS_ESCAPE

Warn about possible 'this' escapes before subclass instance is fully initialized.

TRYback to summary
public static final Lint.LintCategory TRY

Warn about issues relating to use of try blocks (i.e. try-with-resources)

UNCHECKEDback to summary
public static final Lint.LintCategory UNCHECKED

Warn about unchecked operations on raw types.

VARARGSback to summary
public static final Lint.LintCategory VARARGS

Warn about potentially unsafe vararg methods

Constructor Detail

LintCategoryback to summary
private LintCategory(String option, Lint.LintCategory.Property... properties)
LintCategoryback to summary
private LintCategory(List<String> options, Lint.LintCategory.Property... properties)

Method Detail

createLookupback to summary
private static SequencedMap<String, Lint.LintCategory> createLookup()
getback to summary
public static Optional<Lint.LintCategory> get(String option)

Get the LintCategory having the given command line option.

Parameters
option:String

lint category option string

Returns:Optional<Lint.LintCategory>

corresponding LintCategory, or empty if none exists

newEmptySetback to summary
public static EnumSet<Lint.LintCategory> newEmptySet()
optionsback to summary
public static SequencedSet<String> options()

Get all lint category option strings and aliases.

valueOfback to summary
public static Lint.LintCategory valueOf(String name)
valuesback to summary
public static Lint.LintCategory[] values()
com.sun.tools.javac.code back to summary

pack-priv final Enum Lint.LintCategory.Property

extends Enum<Lint.LintCategory.Property>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Lint.LintCategory.Property
public static final Lint.LintCategory.Property

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Lint.LintCategory.Property
public static Lint.LintCategory.Property[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ENABLED_BY_DEFAULTback to summary
public static final Lint.LintCategory.Property ENABLED_BY_DEFAULT
NO_ANNOTATION_SUPPRESSIONback to summary
public static final Lint.LintCategory.Property NO_ANNOTATION_SUPPRESSION

Constructor Detail

Propertyback to summary
private Property()

Method Detail

valueOfback to summary
public static Lint.LintCategory.Property valueOf(String name)
valuesback to summary
public static Lint.LintCategory.Property[] values()