1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Feb 01 10:11:05 2011 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Feb 03 09:35:21 2011 +0000 1.3 @@ -60,7 +60,6 @@ 1.4 1.5 private final Names names; 1.6 private final Log log; 1.7 - private final Resolve rs; 1.8 private final Symtab syms; 1.9 private final Enter enter; 1.10 private final Infer infer; 1.11 @@ -69,6 +68,7 @@ 1.12 private final boolean skipAnnotations; 1.13 private boolean warnOnSyntheticConflicts; 1.14 private boolean suppressAbortOnBadClassFile; 1.15 + private boolean enableSunApiLintControl; 1.16 private final TreeInfo treeinfo; 1.17 1.18 // The set of lint options currently in effect. It is initialized 1.19 @@ -92,7 +92,6 @@ 1.20 1.21 names = Names.instance(context); 1.22 log = Log.instance(context); 1.23 - rs = Resolve.instance(context); 1.24 syms = Symtab.instance(context); 1.25 enter = Enter.instance(context); 1.26 infer = Infer.instance(context); 1.27 @@ -111,13 +110,13 @@ 1.28 skipAnnotations = options.isSet("skipAnnotations"); 1.29 warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); 1.30 suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); 1.31 + enableSunApiLintControl = options.isSet("enableSunApiLintControl"); 1.32 1.33 Target target = Target.instance(context); 1.34 syntheticNameChar = target.syntheticNameChar(); 1.35 1.36 boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION); 1.37 boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED); 1.38 - boolean verboseVarargs = lint.isEnabled(LintCategory.VARARGS); 1.39 boolean verboseSunApi = lint.isEnabled(LintCategory.SUNAPI); 1.40 boolean enforceMandatoryWarnings = source.enforceMandatoryWarnings(); 1.41 1.42 @@ -125,10 +124,10 @@ 1.43 enforceMandatoryWarnings, "deprecated", LintCategory.DEPRECATION); 1.44 uncheckedHandler = new MandatoryWarningHandler(log, verboseUnchecked, 1.45 enforceMandatoryWarnings, "unchecked", LintCategory.UNCHECKED); 1.46 - unsafeVarargsHandler = new MandatoryWarningHandler(log, verboseVarargs, 1.47 - enforceMandatoryWarnings, "varargs", LintCategory.VARARGS); 1.48 sunApiHandler = new MandatoryWarningHandler(log, verboseSunApi, 1.49 enforceMandatoryWarnings, "sunapi", null); 1.50 + 1.51 + deferredLintHandler = DeferredLintHandler.immediateHandler; 1.52 } 1.53 1.54 /** Switch: generics enabled? 1.55 @@ -168,14 +167,14 @@ 1.56 */ 1.57 private MandatoryWarningHandler uncheckedHandler; 1.58 1.59 - /** A handler for messages about unchecked or unsafe vararg method decl. 1.60 - */ 1.61 - private MandatoryWarningHandler unsafeVarargsHandler; 1.62 - 1.63 /** A handler for messages about using proprietary API. 1.64 */ 1.65 private MandatoryWarningHandler sunApiHandler; 1.66 1.67 + /** A handler for deferred lint warnings. 1.68 + */ 1.69 + private DeferredLintHandler deferredLintHandler; 1.70 + 1.71 /* ************************************************************************* 1.72 * Errors and Warnings 1.73 **************************************************************************/ 1.74 @@ -186,6 +185,12 @@ 1.75 return prev; 1.76 } 1.77 1.78 + DeferredLintHandler setDeferredLintHandler(DeferredLintHandler newDeferredLintHandler) { 1.79 + DeferredLintHandler prev = deferredLintHandler; 1.80 + deferredLintHandler = newDeferredLintHandler; 1.81 + return prev; 1.82 + } 1.83 + 1.84 MethodSymbol setMethod(MethodSymbol newMethod) { 1.85 MethodSymbol prev = method; 1.86 method = newMethod; 1.87 @@ -1096,6 +1101,7 @@ 1.88 log.error(tree.pos(), "improperly.formed.type.param.missing"); 1.89 } 1.90 } 1.91 + 1.92 public void visitSelectInternal(JCFieldAccess tree) { 1.93 if (tree.type.tsym.isStatic() && 1.94 tree.selected.type.isParameterized()) { 1.95 @@ -1465,11 +1471,8 @@ 1.96 } 1.97 1.98 // Warn if a deprecated method overridden by a non-deprecated one. 1.99 - if ((other.flags() & DEPRECATED) != 0 1.100 - && (m.flags() & DEPRECATED) == 0 1.101 - && m.outermostClass() != other.outermostClass() 1.102 - && !isDeprecatedOverrideIgnorable(other, origin)) { 1.103 - warnDeprecated(TreeInfo.diagnosticPositionFor(m, tree), other); 1.104 + if (!isDeprecatedOverrideIgnorable(other, origin)) { 1.105 + checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other); 1.106 } 1.107 } 1.108 // where 1.109 @@ -2412,6 +2415,32 @@ 1.110 } 1.111 } 1.112 1.113 + void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) { 1.114 + if ((s.flags() & DEPRECATED) != 0 && 1.115 + (other.flags() & DEPRECATED) == 0 && 1.116 + s.outermostClass() != other.outermostClass()) { 1.117 + deferredLintHandler.report(new DeferredLintHandler.LintLogger() { 1.118 + @Override 1.119 + public void report() { 1.120 + warnDeprecated(pos, s); 1.121 + } 1.122 + }); 1.123 + }; 1.124 + } 1.125 + 1.126 + void checkSunAPI(final DiagnosticPosition pos, final Symbol s) { 1.127 + if ((s.flags() & PROPRIETARY) != 0) { 1.128 + deferredLintHandler.report(new DeferredLintHandler.LintLogger() { 1.129 + public void report() { 1.130 + if (enableSunApiLintControl) 1.131 + warnSunApi(pos, "sun.proprietary", s); 1.132 + else 1.133 + log.strictWarning(pos, "sun.proprietary", s); 1.134 + } 1.135 + }); 1.136 + } 1.137 + } 1.138 + 1.139 /* ************************************************************************* 1.140 * Check for recursive annotation elements. 1.141 **************************************************************************/