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

public Class JCDiagnostic

extends Object
implements Diagnostic<JavaFileObject>
Class Inheritance
All Implemented Interfaces
javax.tools.Diagnostic
Known Direct Subclasses
com.sun.tools.javac.util.JCDiagnostic.MultilineDiagnostic
Imports
java.util.Arrays, .EnumSet, .Locale, .Set, java.util.function.UnaryOperator, java.util.stream.Stream, javax.tools.Diagnostic, .JavaFileObject, com.sun.tools.javac.api.DiagnosticFormatter, com.sun.tools.javac.code.Lint.LintCategory, .Type, com.sun.tools.javac.tree.JCTree, com.sun.tools.javac.util.DefinedBy.Api

An abstraction of a diagnostic message generated by the compiler.

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 record
JCDiagnostic.AnnotatedType

A diagnostic argument that is a type, which will be printed with type annotations.

public static enum
public abstract static class
JCDiagnostic.DiagnosticInfo

A diagnostic key object encapsulates basic properties of a diagnostic, such as the resource key, the arguments and the kind associated with the diagnostic object.

public static interface
JCDiagnostic.DiagnosticPosition

A DiagnosticPosition provides information about the positions in a file that gave rise to a diagnostic.

public static enum
JCDiagnostic.DiagnosticType

A DiagnosticType defines the type of the diagnostic.

public static class
JCDiagnostic.Error

Class representing error diagnostic keys.

public static class
JCDiagnostic.Factory

A factory for creating diagnostic objects.

public static class
JCDiagnostic.Fragment

Class representing fragment diagnostic keys.

public static class
JCDiagnostic.LintWarning

Class representing lint warning diagnostic keys.

public static class
public static class
JCDiagnostic.Note

Class representing note diagnostic keys.

public static class
JCDiagnostic.SimpleDiagnosticPosition

A DiagnosticPosition that simply identifies a position, but no related tree node, as the location for a diagnostic.

pack-priv class
JCDiagnostic.SourcePosition

This class is used to defer the line/column position fetch logic after diagnostic construction.

public static class
JCDiagnostic.Warning

Class representing warning diagnostic keys.

Field Summary

Modifier and TypeField and Description
private DiagnosticFormatter<JCDiagnostic>
private final JCDiagnostic.DiagnosticInfo
private final Set<JCDiagnostic.DiagnosticFlag>
private static DiagnosticFormatter<JCDiagnostic>
fragmentFormatter

Deprecated
private final JCDiagnostic.DiagnosticPosition
private final UnaryOperator<JCDiagnostic>
private final DiagnosticSource
private JCDiagnostic.SourcePosition
sourcePosition

source line position (set lazily)

Constructor Summary

AccessConstructor and Description
protected
JCDiagnostic(DiagnosticFormatter<JCDiagnostic>
the formatter to use for the diagnostic
formatter
,
JCDiagnostic.DiagnosticInfo
the diagnostic key
diagnosticInfo
,
Set<JCDiagnostic.DiagnosticFlag> flags, DiagnosticSource
the name of the source file, or null if none.
source
,
JCDiagnostic.DiagnosticPosition
the character offset within the source file, if given.
pos
)

Create a diagnostic object.

protected
JCDiagnostic(DiagnosticFormatter<JCDiagnostic>
the formatter to use for the diagnostic
formatter
,
JCDiagnostic.DiagnosticInfo
the diagnostic key
diagnosticInfo
,
Set<JCDiagnostic.DiagnosticFlag> flags, DiagnosticSource
the name of the source file, or null if none.
source
,
JCDiagnostic.DiagnosticPosition
the character offset within the source file, if given.
pos
,
UnaryOperator<JCDiagnostic>
the rewriter function used if this diagnostic needs to be rewritten
rewriter
)

Create a diagnostic object.

Method Summary

Modifier and TypeMethod and Description
public static JCDiagnostic
fragment(String
The key for the localized error message.
key
,
Object...
Fields of the error message.
args
)
Deprecated

Create a fragment diagnostic, for use as an argument in other diagnostics

public Object[]

Returns:

the arguments to be included in the text of the diagnostic
getArgs
()

Get the arguments to be included in the text of the diagnostic.

public String
getCode()

Implements javax.tools.Diagnostic.getCode.

Returns a diagnostic code indicating the type of diagnostic.

public long

Returns:

the column number within the line of source referred to by this diagnostic
getColumnNumber
()

Implements javax.tools.Diagnostic.getColumnNumber.

Get the column number within the line of source referred to by this diagnostic.

public JCDiagnostic.DiagnosticPosition
public DiagnosticSource

Returns:

the source referred to with this diagnostic, or null if none
getDiagnosticSource
()

Get the source referred to by this diagnostic.

public long
getEndPosition()

Implements javax.tools.Diagnostic.getEndPosition.

Returns the character offset from the beginning of the file associated with this diagnostic that indicates the end of the problem.

public static DiagnosticFormatter<JCDiagnostic>
getFragmentFormatter()
Deprecated

protected int
protected int
protected int
public Diagnostic.Kind
getKind()

Implements javax.tools.Diagnostic.getKind.

Returns the kind of this diagnostic, for example, error or warning.

public long

Returns:

the line number within the source referred to by this diagnostic
getLineNumber
()

Implements javax.tools.Diagnostic.getLineNumber.

Get the line number within the source referred to by this diagnostic.

public Lint.LintCategory
getLintCategory()

Get the associated lint category, or null if none.

public String
getMessage(Locale locale)

Implements javax.tools.Diagnostic.getMessage.

Returns a localized message for the given locale.

public long
getPosition()

Implements javax.tools.Diagnostic.getPosition.

Returns a character offset from the beginning of the source object associated with this diagnostic that indicates the location of the problem.

public String

Returns:

the prefix string associated with this type of diagnostic
getPrefix
()

Get the prefix string associated with this type of diagnostic.

public String

Returns:

the prefix string associated with a particular type of diagnostic
getPrefix
(JCDiagnostic.DiagnosticType dt)

Get the prefix string associated with a particular type of diagnostic.

public JavaFileObject

Returns:

the name of the source referred to with this diagnostic, or null if none
getSource
()

Implements javax.tools.Diagnostic.getSource.

Get the name of the source file referred to by this diagnostic.

public long
getStartPosition()

Implements javax.tools.Diagnostic.getStartPosition.

Returns the character offset from the beginning of the file associated with this diagnostic that indicates the start of the problem.

public List<JCDiagnostic>

Returns:

subdiagnostic list
getSubdiagnostics
()

Get the subdiagnostic list

public JCDiagnostic.DiagnosticType

Returns:

the type of this diagnostic
getType
()

Get the type of this diagnostic.

public boolean
hasLintCategory()

Check whether this diagnostic has an associated lint category.

pack-priv boolean
public boolean
public boolean

Returns:

true if this diagnostic is required to be shown.
isMandatory
()

Check whether or not this diagnostic is required to be shown.

public boolean
pack-priv JCDiagnostic
public void
public String
toString()

Overrides java.lang.Object.toString.

Return the standard presentation of this diagnostic.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait