Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javadoc displaying value on an inner class constant using @value

I have an inner class which declares a constant and want to display its value in Javadoc of the enclosing top-level class using the @value annotation. For example:

/**  * {@value #FOO_CONS} // this displays well  * {@value #BAR_CONS} // this does not work (checked in the latest Eclipse)  * {@value Bar#BAR_CONS} // this does not work, either  */ public Foo {   public static final int FOO_CONS = 1;   static class Bar {     public static final int BAR_CONS = 42;   } } 

Any ideas how to display the value of BAR_CONS in Javadoc of the Foo class (or any other class, in general)?

like image 406
eold Avatar asked Jul 11 '12 06:07

eold


People also ask

What does @SEE do in Javadoc?

In short, we use the @see tag when we want a link or a text entry that points to a reference. This tag adds a “See Also” heading to the reference. A document comment can hold any number of @see tags, all of which can be grouped under the same heading.

How do you declare a constant variable in Java?

To make any variable a constant, we must use 'static' and 'final' modifiers in the following manner: Syntax to assign a constant value in java: static final datatype identifier_name = constant; The static modifier causes the variable to be available without an instance of it's defining class being loaded.

How do you write Javadoc comments for variables?

Writing Javadoc Comments In general, Javadoc comments are any multi-line comments (" /** ... */ ") that are placed before class, field, or method declarations. They must begin with a slash and two stars, and they can include special tags to describe characteristics like method parameters or return values.


2 Answers

Javadoc format for constant defined in another package should be:
{@value package.class#field}

However, it potentially not rendering is a known issue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=342194

like image 61
Scott Avatar answered Sep 20 '22 07:09

Scott


if create javadoc for members with visibility "package" (which is the visibility for your Bar class) i get the constant in the javadoc under Foo.Bar

like image 24
user2340612 Avatar answered Sep 19 '22 07:09

user2340612