--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Aug 11 17:02:00 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Fri Aug 12 11:49:18 2016 +0530
@@ -3197,6 +3197,21 @@
log.warning(LintCategory.DEP_ANN,
pos, "missing.deprecated.annotation");
}
+ // Note: @Deprecated has no effect on local variables, parameters and package decls.
+ if (lint.isEnabled(LintCategory.DEPRECATION)) {
+ if (!syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) != null) {
+ switch (s.getKind()) {
+ case LOCAL_VARIABLE:
+ case PACKAGE:
+ case PARAMETER:
+ case RESOURCE_VARIABLE:
+ case EXCEPTION_PARAMETER:
+ log.warning(LintCategory.DEPRECATION, pos,
+ "deprecated.annotation.has.no.effect", Kinds.kindName(s));
+ break;
+ }
+ }
+ }
}
void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) {