JDK 18 introduces JEP 413, which adds a new `@snippet` tag to Javadoc that lets developers reference code from external source files. These external files can be compiled and tested, ensuring documentation examples stay accurate and up to date. The tag supports regions to show only relevant code sections, text highlighting, linking, and inline-plus-external validation. Projects targeting older Java versions can still use this feature by building with JDK 18 while setting the compiler's `--release` flag to their target version.
Sort: