1.1 --- a/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java Mon Jul 26 14:18:45 2010 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java Mon Jul 26 14:25:56 2010 -0700 1.3 @@ -29,6 +29,7 @@ 1.4 import java.util.Set; 1.5 import javax.tools.JavaFileObject; 1.6 1.7 +import com.sun.tools.javac.code.Lint.LintCategory; 1.8 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 1.9 1.10 1.11 @@ -105,13 +106,16 @@ 1.12 * True if mandatory warnings and notes are being enforced. 1.13 * @param prefix A common prefix for the set of message keys for 1.14 * the messages that may be generated. 1.15 + * @param lc An associated lint category for the warnings, or null if none. 1.16 */ 1.17 public MandatoryWarningHandler(Log log, boolean verbose, 1.18 - boolean enforceMandatory, String prefix) { 1.19 + boolean enforceMandatory, String prefix, 1.20 + LintCategory lc) { 1.21 this.log = log; 1.22 this.verbose = verbose; 1.23 this.prefix = prefix; 1.24 this.enforceMandatory = enforceMandatory; 1.25 + this.lintCategory = lc; 1.26 } 1.27 1.28 /** 1.29 @@ -235,15 +239,22 @@ 1.30 private final boolean enforceMandatory; 1.31 1.32 /** 1.33 + * A LintCategory to be included in point-of-use diagnostics to indicate 1.34 + * how messages might be suppressed (i.e. with @SuppressWarnings). 1.35 + */ 1.36 + private final LintCategory lintCategory; 1.37 + 1.38 + /** 1.39 * Reports a mandatory warning to the log. If mandatory warnings 1.40 * are not being enforced, treat this as an ordinary warning. 1.41 */ 1.42 private void logMandatoryWarning(DiagnosticPosition pos, String msg, 1.43 Object... args) { 1.44 + // Note: the following log methods are safe if lintCategory is null. 1.45 if (enforceMandatory) 1.46 - log.mandatoryWarning(pos, msg, args); 1.47 + log.mandatoryWarning(lintCategory, pos, msg, args); 1.48 else 1.49 - log.warning(pos, msg, args); 1.50 + log.warning(lintCategory, pos, msg, args); 1.51 } 1.52 1.53 /**