Closed
Description
Record classes are unmodifiable data class introduced in Java 16 and included in the recent LTS version Java 17. Since records are a new syntax for Java, they generate an ElementKind.RECORD
AST element instead of ElementKind.CLASS
and are not supported by the current visitor.
Javadoc for a record is the same as a regular class, except it may include @param
fields referring to record components:
/**
* Example class.
*
* @param a first component input
* @param b second input
*/
public class Foo(boolean a, String b) {
/** Alternate constructor */
public Foo(boolean a) {
this(a, null);
}
}
General thoughts:
- As best as I can tell, the compiler doesn't attach any docs to the generated fields or methods, or to the primary constructor
- There's no way to directly comment the record components
Depending on how an implementation might balance representation vs. intent:
- The class docs could be re-applied to the primary constructor, which can be determined by the
GENERATED
orRECORD
flags set on the method (which I think is specified, but I can't find the exact mention in the JVM spec) @param
tags from the primary constructor could be applied to the fields and/or methods