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

public Class Log

extends AbstractLog
Class Inheritance
Known Direct Subclasses
com.sun.tools.javac.api.JavacTaskPool.ReusableContext.ReusableLog
Imports
java.io.*, java.util.ArrayList, .Arrays, .Comparator, .EnumMap, .EnumSet, .HashSet, .LinkedHashMap, .LinkedList, .List, .Map, .Optional, .Set, java.util.concurrent.atomic.AtomicBoolean, java.util.function.Predicate, javax.tools.DiagnosticListener, .JavaFileObject, com.sun.tools.javac.api.DiagnosticFormatter, com.sun.tools.javac.code.Flags, .Lint, .Lint.LintCategory, .LintMapper, .Source, .Symbol, com.sun.tools.javac.comp.AttrContext, .Env, com.sun.tools.javac.main.Main, .Option, com.sun.tools.javac.tree.JCTree, com.sun.tools.javac.tree.JCTree.*, .TreeInfo, .TreeScanner, com.sun.tools.javac.util.JCDiagnostic.DiagnosticInfo, .JCDiagnostic.DiagnosticPosition, .JCDiagnostic.DiagnosticType, .JCDiagnostic.LintWarning

A class for error logs. Reports errors and warnings, and keeps track of error numbers and positions.

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
private class
Log.DefaultDiagnosticHandler

Common diagnostic handling.

public class
Log.DeferredDiagnosticHandler

A DiagnosticHandler that can defer some or all diagnostics, by buffering them for later examination and/or reporting.

public abstract class
Log.DiagnosticHandler

DiagnosticHandler's provide the initial handling for diagnostics.

public class
Log.DiscardDiagnosticHandler

A DiagnosticHandler that discards all diagnostics.

public static enum
public static enum

Field Summary

Modifier and TypeField and Description
private final EnumMap<Lint.LintCategory, WarningAggregator>
public boolean
compressedOutput

Set to true if a compressed diagnostic is reported

private final Context
context

The compilation context.

private DiagnosticFormatter<JCDiagnostic>
diagFormatter

Formatter for diagnostics.

protected DiagnosticListener<? super JavaFileObject>
diagListener

Diagnostic listener, if provided through programmatic interface to javac (JSR 199).

private Log.DiagnosticHandler
diagnosticHandler

Handler for initial dispatch of diagnostics.

public boolean
dumpOnError

Print stack trace on errors?

public boolean
emitWarnings

Switch: emit warning messages.

public static final Context.Key<PrintWriter>
errKey

The context key for the diagnostic PrintWriter.

public Set<String>
expectDiagKeys

Keys for expected diagnostics.

private final LintMapper
lintMapper

The lint positions table.

public final EnumSet<Lint.LintCategory>
lintWarnings

Tracks whether any warnings have been encountered in each LintCategory.

public static final Context.Key<Log>
logKey

The context key for the log.

protected int
MaxErrors

The maximum number of errors/warnings that are reported.

protected int
private JavacMessages
messages

JavacMessages object used for localization.

public int
nerrors

The number of errors encountered so far.

public int
nonLintWarnings

The total number of non-lint warnings encountered so far.

public int
nsuppressederrors

The number of errors encountered after MaxErrors was reached.

public int
nsuppressedwarns

The number of warnings encountered after MaxWarnings was reached.

public int
nwarnings

The total number of warnings encountered so far.

private final Options
options

The Options singleton.

public static final Context.Key<PrintWriter>
outKey

The context key for the standard output PrintWriter.

public boolean
promptOnError

Switch: prompt user on each error.

protected Set<Pair<JavaFileObject, Integer>>
recorded

A set of all errors generated so far.

protected Set<Pair<JavaFileObject, List<String>>>
recordedSourceLevelErrors

A set of "not-supported-in-source-X" errors produced so far.

private Lint
rootLint

The root Lint singleton.

private final EnumSet<Lint.LintCategory>
public boolean
suppressNotes

Switch: suppress note messages.

private static boolean
private final Map<Log.WriterKind, PrintWriter>
Inherited from com.sun.tools.javac.util.AbstractLog:
diagssourcesourceMap

Constructor Summary

AccessConstructor and Description
protected
Log(Context context)

Construct a log with default settings.

protected
Log(Context context, PrintWriter writer)

Construct a log with all output sent to a single output stream.

protected
Log(Context context, PrintWriter out, PrintWriter err)

Construct a log.

private
Log(Context
the context in which the log should be registered
context
,
Map<Log.WriterKind, PrintWriter>
a map of writers that can be accessed by the kind of writer required
writers
)

Creates a log.

Method Summary

Modifier and TypeMethod and Description
private WarningAggregator
public void
clear()

Reset the state of this instance.

public JavaFileObject
currentSourceFile()

Return current sourcefile.

protected void
public void
flush()

Flush the logs

public void
public static String
format(String fmt, Object... args)

private List<String>
private void
protected int
getDefaultMaxErrors()

Default value for -Xmaxerrs.

protected int
getDefaultMaxWarnings()

Default value for -Xmaxwarns.

public DiagnosticFormatter<JCDiagnostic>
getDiagnosticFormatter()

Get the current diagnostic formatter.

private int
getIntOption(Options options, Option option, int defaultValue)

public static String
getLocalizedString(String
The key for the localized string.
key
,
Object...
Fields to substitute into the string.
args
)

Find a localized string in the resource bundle.

public PrintWriter
protected PrintWriter
public boolean
public boolean
hasErrorOn(JCDiagnostic.DiagnosticPosition pos)

Is an error reported at the given pos (inside the current source)?

private void
private static Map<Log.WriterKind, PrintWriter>

Returns:

a map of writers
initWriters
(Context
the context in which to find writers to use
context
)

Initialize a map of writers based on values found in the context

private static Map<Log.WriterKind, PrintWriter>

Returns:

a map of writers
initWriters
(PrintWriter
a stream to be used for normal output
out
,
PrintWriter
a stream to be used for diagnostic messages, such as errors, warnings, etc
err
)

Initialize a writer map for a stream for normal output, and a stream for diagnostics.

public static Log
instance(Context context)

Get the Log instance for this context.

private Lint
public String
localize(String
The key for the localized string.
key
,
Object...
Fields to substitute into the string.
args
)

Find a localized string in the resource bundle.

public String
public String
localize(Log.PrefixKind pk, String
The key for the localized string.
key
,
Object...
Fields to substitute into the string.
args
)

Find a localized string in the resource bundle.

public void
popDiagnosticHandler(Log.DiagnosticHandler h)

Replace the specified diagnostic handler with the handler that was current at the time this handler was created.

public static void
preRegister(Context context, PrintWriter w)

Register a Context.Factory to create a Log.

private void
printErrLine(int
Buffer index of the error position, must be on current line
pos
,
PrintWriter writer)

Print the faulty source code line and point to the error.

public void
printLines(String key, Object... args)

public void
public void
public void
public void
public void
public void
private void
printRawDiag(PrintWriter pw, String prefix, int pos, String msg)

print an error or warning message:

public void
printRawLines(String msg)

Print the text of a message, translating newlines appropriately for the platform.

public void
printRawLines(Log.WriterKind kind, String msg)

Print the text of a message, translating newlines appropriately for the platform.

public static void
printRawLines(PrintWriter writer, String msg)

Print the text of a message, translating newlines appropriately for the platform.

public void
printVerbose(String key, Object... args)

Print the localized text of a "verbose" message to the noticeWriter stream.

public void
prompt()

Prompt user after an error.

public void
rawError(int pos, String msg)

report an error:

public void
rawWarning(int pos, String msg)

report a warning:

public void
report(JCDiagnostic diagnostic)

Implements abstract com.sun.tools.javac.util.AbstractLog.report.

Primary method to report a diagnostic.

public void
reportOutstandingNotes()

Report any remaining unreported aggregated mandatory warning notes.

public void
reportOutstandingWarnings()

Report unreported lint warnings for which the applicable Lint configuration is now known.

private Lint
public void
setDiagnosticFormatter(DiagnosticFormatter<JCDiagnostic> diagFormatter)

Set the current diagnostic formatter.

public void
public void
protected boolean
shouldReport(JavaFileObject file, int pos)

Returns true if an error needs to be reported for a given source name and pos.

private boolean
shouldReport(JCDiagnostic d)

Returns true if a diagnostics needs to be reported.

public void
suppressAggregatedWarningNotes(Lint.LintCategory category)

Suppress aggregated mandatory warning notes for the specified category.

protected void
writeDiagnostic(JCDiagnostic diag)

Write out a diagnostic and bump the warning and error counters as needed.

Inherited from com.sun.tools.javac.util.AbstractLog:
currentSourceerrorerrorerrorerrorerrorerrorerrorgetSourcenotenotenotenotenoteuseSourcewarningwarningwarningwarningwarning