--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Sep 01 13:21:52 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Fri Sep 02 07:49:15 2016 +0530
@@ -3192,7 +3192,7 @@
}
void checkDeprecatedAnnotation(DiagnosticPosition pos, Symbol s) {
- if (lint.isEnabled(LintCategory.DEP_ANN) &&
+ if (lint.isEnabled(LintCategory.DEP_ANN) && s.isDeprecatableViaAnnotation() &&
(s.flags() & DEPRECATED) != 0 &&
!syms.deprecatedType.isErroneous() &&
s.attribute(syms.deprecatedType.tsym) == null) {
@@ -3200,18 +3200,10 @@
pos, "missing.deprecated.annotation");
}
// Note: @Deprecated has no effect on local variables, parameters and package decls.
- if (lint.isEnabled(LintCategory.DEPRECATION)) {
+ if (lint.isEnabled(LintCategory.DEPRECATION) && !s.isDeprecatableViaAnnotation()) {
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;
- }
+ log.warning(LintCategory.DEPRECATION, pos,
+ "deprecated.annotation.has.no.effect", Kinds.kindName(s));
}
}
}