What does @Deprecated mean on method parameters and local variables?

The JLS expressly states that the @Deprecation annotation is ignored on local variables. See Matt Ball's answer.

Is this something they might intend to implement in the future?

I very much doubt it.

  • What could it mean ... apart from its current meaning as an informal reminder to the implementor (and maybe style checkers / PMD / FindBugs / etc) that the local variable needs to be removed.

  • Any material change is likely to break source compatibility for people who currently use the annotation as above. The Java maintainers try very hard to avoid breaking old code.


What does it mean to mark a method parameter or a local variable as @Deprecated?

It has the same meaning as when applied to any other element:

A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists. Compilers warn when a deprecated program element is used or overridden in non-deprecated code.


Why doesn't the compiler omit warnings for deprecated parameters and fields in Java 7?
Because that's exactly what the JLS (§ 9.6.3.6) dictates.

A Java compiler must produce a deprecation warning when a type, method, field, or constructor whose declaration is annotated with the annotation @Deprecated is used (i.e. overridden, invoked, or referenced by name), unless:

  • The use is within an entity that is itself annotated with the annotation @Deprecated; or

  • The use is within an entity that is annotated to suppress the warning with the annotation @SuppressWarnings("deprecation"); or

  • The use and declaration are both within the same outermost class.

Use of the @Deprecated annotation on a local variable declaration or on a parameter declaration has no effect.

(emphasis added)