Ryan
Ryan

Reputation: 10141

Eclipse @deprecated not working, but @Deprecated work

In my Eclipse Indigo, only @Deprecated work but not @deprecated in comment, any idea?

e.g.

// @deprecated <-- not work
@Deprecated    <-- work
public String getName()
{
    return name;
}

Upvotes: 2

Views: 644

Answers (4)

Mark Rotteveel
Mark Rotteveel

Reputation: 109281

Your comment is not a javadoc comment so it is ignored by Eclipse. If you would have used

/**
 * @deprecated
 */

then Eclipse would have handled it exactly the same as when you specify the @Deprecated annotation.

Upvotes: 2

Kumar Vivek Mitra
Kumar Vivek Mitra

Reputation: 33544

1. Annotation types are, in fact, a form of interface.

2. the @Deprecated annotation indicates that the marked element is deprecated and should no longer be used.

3. When an element is deprecated, it should also be documented using the Javadoc @deprecated tag, which means that @deprecated is only for the use in Javadoc documentation, and not for applying on the methods.

For more details see this:

http://docs.oracle.com/javase/tutorial/java/javaOO/annotations.html

Upvotes: 2

Reimeus
Reimeus

Reputation: 159874

@Deprecated is a marker interface whereas deprecated is not. @deprecated is a Javadoc Tag.

Upvotes: 7

Louis Wasserman
Louis Wasserman

Reputation: 198591

I believe @deprecated is only for use in Javadoc comments in explaining deprecation, and is not itself an annotation usable on methods.

Upvotes: 3

Related Questions