langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java
--- a/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java Fri Jun 20 11:25:03 2008 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java Wed Jun 25 14:24:53 2008 -0700
@@ -101,13 +101,17 @@
* individual instances should be given, or whether an aggregate
* message should be generated at the end of the compilation.
* Typically set via -Xlint:option.
+ * @param enforceMandatory
+ * True if mandatory warnings and notes are being enforced.
* @param prefix A common prefix for the set of message keys for
* the messages that may be generated.
*/
- public MandatoryWarningHandler(Log log, boolean verbose, String prefix) {
+ public MandatoryWarningHandler(Log log, boolean verbose,
+ boolean enforceMandatory, String prefix) {
this.log = log;
this.verbose = verbose;
this.prefix = prefix;
+ this.enforceMandatory = enforceMandatory;
}
/**
@@ -122,7 +126,7 @@
if (log.nwarnings < log.MaxWarnings) {
// generate message and remember the source file
- log.mandatoryWarning(pos, msg, args);
+ logMandatoryWarning(pos, msg, args);
sourcesWithReportedWarnings.add(currentSource);
} else if (deferredDiagnosticKind == null) {
// set up deferred message
@@ -163,12 +167,12 @@
public void reportDeferredDiagnostic() {
if (deferredDiagnosticKind != null) {
if (deferredDiagnosticArg == null)
- log.mandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix));
+ logMandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix));
else
- log.mandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix), deferredDiagnosticArg);
+ logMandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix), deferredDiagnosticArg);
if (!verbose)
- log.mandatoryNote(deferredDiagnosticSource, prefix + ".recompile");
+ logMandatoryNote(deferredDiagnosticSource, prefix + ".recompile");
}
}
@@ -224,4 +228,32 @@
* deferredDiagnosticKind is updated.
*/
private Object deferredDiagnosticArg;
+
+ /**
+ * True if mandatory warnings and notes are being enforced.
+ */
+ private final boolean enforceMandatory;
+
+ /**
+ * Reports a mandatory warning to the log. If mandatory warnings
+ * are not being enforced, treat this as an ordinary warning.
+ */
+ private void logMandatoryWarning(DiagnosticPosition pos, String msg,
+ Object... args) {
+ if (enforceMandatory)
+ log.mandatoryWarning(pos, msg, args);
+ else
+ log.warning(pos, msg, args);
+ }
+
+ /**
+ * Reports a mandatory note to the log. If mandatory notes are
+ * not being enforced, treat this as an ordinary note.
+ */
+ private void logMandatoryNote(JavaFileObject file, String msg, Object... args) {
+ if (enforceMandatory)
+ log.mandatoryNote(file, msg, args);
+ else
+ log.note(file, msg, args);
+ }
}