Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaDoc: @link to MyClass.class

Tags:

java

javadoc

Is there correct JavaDoc syntax for {@link Foo.class}? Neither this, nor {@link Foo#class} works. Or is this not possible?

Let me expand a bit:

I have a function registerException(Class<? extends Exception> exceptionClass) that get's called with things like registerException(IOException.class) and started writing the following JavaDoc for it:

/**
 * Registers a new {@link Class Class&lt;? extends Exception&gt;}
 * (e.g. <code>IOException.class</code>} that can be flattened by this handler.
 * 
 * @param exceptionClass - the exception class
 */

and I was thinking whether I could place a {@link ...} around IOException.class.

like image 968
Markus A. Avatar asked May 03 '14 20:05

Markus A.


People also ask

How do you refer to a class in Javadoc?

Javadoc provides the @link inline tag for referencing the members in the Java classes. We can think of the @link tag as similar to the anchor tag in HTML, which is used to link one page to another via hyperlinks. Similar to the anchor tag, the path_to_member is the destination, and the label is the display text.

What does @SEE mean 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.

Do you Javadoc a constructor?

It's a best practice to include a constructor in a class. However, if the constructor is omitted, Javadoc automatically creates a constructor in the Javadoc but omits any description of the constructor.

Do overridden methods need Javadoc?

All public methods must have a doc comment except: Methods that implement or override a method in an interface or superclass without adding any interesting behaviour beyond what is already documented for the overridden method.


1 Answers

The .class is not needed (and apparently doesn't work).

As noted in a comment, {@link IOException IOException.class} should create a link with an appropriate text label.

like image 73
Don Roby Avatar answered Oct 15 '22 11:10

Don Roby