Documenting record compact constructor
Daniel Fuchs
daniel.fuchs at oracle.com
Tue Nov 24 12:31:34 UTC 2020
Hi,
What is the canonical way of documenting a record compact constructor?
Consider the following dummy record class:
=========================================================
import java.util.Objects;
/**
* A class that represents a person's name.
*
* @param name the person's first name
* @param surname the person's surname.
*/
public record Name(String name, String surname) {
/**
* Creates a new instance of {@code Name}.
*
* @throws NullPointerException if either {@code name} or
* {@code surname} is null;
*/
Name {
Objects.requiresNonNull(name);
Objects.requiresNonNull(surname);
}
}
==========================================================
We have noticed that in this case, javadoc will generate a
warning, and the API documentation generated for the
canonical constructor will not include the documentation
of the `name` and `surname` parameters:
Name.java:16: warning: no @param for name
public Name {
^
Name.java:16: warning: no @param for surname
public Name {
^
Shouldn't the @param be derived from the component description
in the class level javadoc (at lines 6-7)?
best regards,
-- daniel
More information about the javadoc-dev
mailing list