Skip to content

Unused Javadoc tag with annotation @return #2141

Closed

Description

@philwebb

As discussed in SourceForge Bug 543 and on the Google groups the following code:

@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SomeAnnotation {

    /**
     * Some description.
     * @return something
     */
    String value() default "";

}

Will fail with the message:

Unused Javadoc tag

Despite an explicit test for this, I believe that the assumption is wrong and @return tags can (and should) be used with annotation types.

Activity

  1. added a commit that references this issue on Sep 8, 2015
  2. romani commented on Sep 8, 2015

    @romani
    Member

    found one example http://grepcode.com/file_/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/lang/annotation/Repeatable.java/?v=source
    but wee need to find more to get to know why it was not used and why it is started to use, we might need to ask community on stackoverflow.

    Look like jdk started to do that from java8 http://grepcode.com/file_/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/lang/SuppressWarnings.java/?v=source (at java6 there was no return tag)

    Confirmed: all other annotations of jdk got return tag in java8 and jdk9.

  3. added this to the 6.11 milestone on Sep 8, 2015
  4. philwebb commented on Sep 8, 2015

    @philwebb
    ContributorAuthor

    See androidannotations/androidannotations#1198 (comment) for some discussion on the subject. Java 8 tightened the JavaDoc compiler to actually fail if @return tags are missing.

    The @SupressWarnings example that you gave has been updated in Java 8 to include @Return tags. See http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/SuppressWarnings.java#l69

  5. mcandre commented on Mar 29, 2016

    @mcandre

    What's the current state of checkstyle re: @return docs for annotations? Does checkstyle now allow for these? Which checkstyle version has the fix?

  6. romani commented on Apr 1, 2016

    @romani
    Member

    checkstyle should allow @return tag (no violation).

    problems was fixed at f7698ed
    (look at tags "... checkstyle-6.11")

    Github Milestone is 6.11, so it is released as 6.11 - http://checkstyle.sourceforge.net/releasenotes.html#Release_6.11.
    6.11 had 2 bug fixes so please use - 6.11.2 or latest 6.17.

    if smth does not work - please report an issue with all details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions