[JSR308] Annotation ambiguity

Alexey Kudravtsev cdracm at mail.ru
Thu May 21 11:05:56 EDT 2009


Please consider this example:

class S {
 @Deprecated int foo() { return 0; }

Does the @Deprecated annotation apply to the method foo, or method return type?

According to JLS, since the Deprecated class lacks any @Target annotations, it can be applied to any element.
Therefore, it applies to both 'int' data type and method foo.
Which does not make any sense, in my opinion.

Alexey Kudravtsev
Software Developer
JetBrains, Inc, http://www.jetbrains.com
"Develop with pleasure!"

More information about the JSR308 mailing list