@Exported

# Package com.sun.javadoc

The Doclet API (also called the Javadoc API) provides a mechanism for clients to inspect the source-level structure of programs and libraries, including javadoc comments embedded in the source.

See: Description

- Interface Summary
  Interface | Description
  --- | ---
  AnnotatedType | Represents an annotated type.
  AnnotationDesc | Represents an annotation.
  AnnotationDesc.ElementValuePair | Represents an association between an annotation type element and one of its values.
  AnnotationTypeDoc | Represents an annotation type.
  AnnotationTypeElementDoc | Represents an element of an annotation type.
  AnnotationValue | Represents a value of an annotation type element.
  ClassDoc | Represents a java class or interface and provides access to information about the class, the class's comment and tags, and the members of the class.
  ConstructorDoc | Represents a constructor of a java class.
  Doc | Represents Java language constructs (package, class, constructor, method, field) which have comments and have been processed by this run of javadoc.
  DocErrorReporter | This interface provides error, warning and notice printing.
  ExecutableMemberDoc | Represents a method or constructor of a java class.
  FieldDoc | Represents a field in a java class.
  MemberDoc | Represents a member of a java class: field, constructor, or method.
  MethodDoc | Represents a method of a java class.
  PackageDoc | Represents a java package.
  Parameter | Parameter information.
  ParameterizedType | Represents an invocation of a generic class or interface.
  ParamTag | Represents an @param documentation tag.
  ProgramElementDoc | Represents a java program element: class, interface, field, constructor, or method.
  RootDoc | Represents the root of the program structure information for one run of javadoc.
  SeeTag | Represents a user-defined cross-reference to related documentation.
  SerialFieldTag | Documents a Serializable field defined by an ObjectStreamField.
  SourcePosition | This interface describes a source position: filename, line number, and column number.
  Tag | Represents a simple documentation tag, such as @since, @author, @version.
  ThrowsTag | Represents a @throws or @exception documentation tag.
  Type | Represents a type.
  TypeVariable | Represents a type variable.
  WildcardType | Represents a wildcard type argument.

- Class Summary
  Class | Description
  --- | ---
  Doclet | This is an example of a starting class for a doclet, showing the entry-point methods.

- Enum Summary
  Enum | Description
  --- | ---
  LanguageVersion | Java Programming Language version.

## Package com.sun.javadoc Description

The Doclet API (also called the Javadoc API) provides a mechanism for clients to inspect the source-level structure of programs and libraries, including javadoc comments embedded in the source. This is useful for documentation, program checking, automatic code generation and many other tools.

Doclets are invoked by javadoc and use this API to write out program information to files. For example, the standard doclet is called by default and writes out documentation to HTML files.

The invocation is defined by the abstract `Doclet` class -- the entry point is the `start` method:

        public static boolean start(RootDoc root)

The `RootDoc` instance holds the root of the program structure information. From this root all other program structure information can be extracted.

### Terminology

When calling javadoc, you pass in package names and source file names -- these are called the specified packages and classes. You also pass in Javadoc options; the access control Javadoc options (`-public`, `-protected`, `-package`, and `-private`) filter program elements, producing a result set, called the included set, or "documented" set. (The unfiltered set is also available through `allClasses(false)`.)

Throughout this API, the term class is normally a shorthand for "class or interface", as in: `ClassDoc`, `allClasses()`, and `findClass(String)`. In only a couple of other places, it means "class, as opposed to interface", as in: `Doc.isClass()`. In the second sense, this API calls out four kinds of classes: ordinary classes, enums, errors and exceptions. Throughout the API, the detailed description of each program element describes explicitly which meaning is being used.

A qualified class or interface name is one that has its package name prepended to it, such as `java.lang.String`. A non-qualified name has no package name, such as `String`.

### Example

The following is an example doclet that displays information in the `@param` tags of the processed classes:

    import com.sun.javadoc.*;

    public class ListParams extends Doclet {

        public static boolean start(RootDoc root) {
            ClassDoc[] classes = root.classes();
            for (int i = 0; i < classes.length; ++i) {
                ClassDoc cd = classes[i];
                printMembers(cd.constructors());
                printMembers(cd.methods());
            }
            return true;
        }

        static void printMembers(ExecutableMemberDoc[] mems) {
            for (int i = 0; i < mems.length; ++i) {
                ParamTag[] params = mems[i].paramTags();
                System.out.println(mems[i].qualifiedName());
                for (int j = 0; j < params.length; ++j) {
                    System.out.println("   " + params[j].parameterName()
                        + " - " + params[j].parameterComment());
                }
            }
        }
    }

Interfaces and methods from the Javadoc API are marked in red. `Doclet` is an abstract class that specifies the invocation interface for doclets, `Doclet` holds class or interface information, `ExecutableMemberDoc` is a superinterface of `MethodDoc` and `ConstructorDoc`, and `ParamTag` holds information from "`@param`" tags.

This doclet when invoked with a command line like:

        javadoc -doclet ListParams -sourcepath <source-location> java.util

producing output like:

        ...
        java.util.ArrayList.add
           index - index at which the specified element is to be inserted.
           element - element to be inserted.
        java.util.ArrayList.remove
           index - the index of the element to removed.
        ...

See Also:
  `Doclet`, `RootDoc`

Submit a bug or feature
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.