From dc6c96bbaf1c0af3eacaa2e59646ed7c5bb0767d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Tue, 8 Jun 2021 18:22:16 +0000 Subject: [PATCH] 8263468: New page for "recent" new API Reviewed-by: erikj, jjg --- make/Docs.gmk | 6 + make/autoconf/jdk-version.m4 | 2 + make/autoconf/spec.gmk.in | 3 + make/conf/version-numbers.conf | 1 + .../doclets/formats/html/Contents.java | 4 + .../formats/html/DeprecatedListWriter.java | 41 +- .../doclets/formats/html/HelpWriter.java | 27 +- .../formats/html/HtmlConfiguration.java | 11 +- .../doclets/formats/html/HtmlDoclet.java | 26 +- .../formats/html/HtmlDocletWriter.java | 3 +- .../doclets/formats/html/Navigation.java | 51 +- .../formats/html/NewAPIListWriter.java | 135 +++ .../formats/html/PreviewListWriter.java | 3 +- .../formats/html/SummaryListWriter.java | 29 +- .../internal/doclets/formats/html/Table.java | 13 +- .../formats/html/markup/HtmlStyle.java | 10 + .../html/resources/standard.properties | 32 +- .../internal/doclets/toolkit/BaseOptions.java | 43 + .../util/DeprecatedAPIListBuilder.java | 8 +- .../doclets/toolkit/util/DocPaths.java | 5 +- .../doclets/toolkit/util/NewAPIBuilder.java | 69 ++ .../toolkit/util/PreviewAPIListBuilder.java | 1 + .../toolkit/util/SummaryAPIListBuilder.java | 13 +- .../internal/doclets/toolkit/util/Utils.java | 26 +- .../TestDeprecatedDocs.java | 14 +- .../TestHtmlTableStyles.java | 4 +- .../testHtmlTableTags/TestHtmlTableTags.java | 4 +- .../doclet/testModules/TestModules.java | 2 +- .../doclet/testNewApiList/TestNewApiList.java | 884 ++++++++++++++++++ .../testNewApiList/mdl/module-info.java | 30 + .../mdl/pkg/TestAnnotation.java | 51 + .../testNewApiList/mdl/pkg/TestClass.java | 68 ++ .../testNewApiList/mdl/pkg/TestEnum.java | 53 ++ .../testNewApiList/mdl/pkg/TestError.java | 49 + .../testNewApiList/mdl/pkg/TestException.java | 49 + .../testNewApiList/mdl/pkg/TestInterface.java | 49 + .../testNewApiList/mdl/pkg/TestRecord.java | 41 + .../testNewApiList/mdl/pkg/package-info.java | 28 + .../doclet/testNewApiList/pkg/TestClass.java | 68 ++ .../testRecordTypes/TestRecordTypes.java | 4 +- 40 files changed, 1886 insertions(+), 74 deletions(-) create mode 100644 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NewAPIListWriter.java create mode 100644 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/NewAPIBuilder.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/TestNewApiList.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/module-info.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestAnnotation.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestClass.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestEnum.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestError.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestException.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestInterface.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestRecord.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/package-info.java create mode 100644 test/langtools/jdk/javadoc/doclet/testNewApiList/pkg/TestClass.java diff --git a/make/Docs.gmk b/make/Docs.gmk index 612880df2f8..ef1651eaf4e 100644 --- a/make/Docs.gmk +++ b/make/Docs.gmk @@ -332,6 +332,12 @@ define SetupApiDocsGenerationBody $$(eval $$(call create_overview_file,$1)) $1_OPTIONS += -overview $$($1_OVERVIEW) + # Add summary pages for new/deprecated APIs in recent releases + $1_OPTIONS += --since $(call CommaList, \ + $(filter-out $(VERSION_DOCS_API_SINCE), \ + $(call sequence, $(VERSION_DOCS_API_SINCE), $(VERSION_FEATURE)))) + $1_OPTIONS += --since-label "New API since JDK $(VERSION_DOCS_API_SINCE)" + $$(foreach g, $$($1_GROUPS), \ $$(eval $1_OPTIONS += -group "$$($$g_GROUP_NAME)" "$$($$g_GROUP_MODULES)") \ ) diff --git a/make/autoconf/jdk-version.m4 b/make/autoconf/jdk-version.m4 index f61478b85fa..092e7a6f490 100644 --- a/make/autoconf/jdk-version.m4 +++ b/make/autoconf/jdk-version.m4 @@ -533,6 +533,7 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], # We could define --with flags for these, if really needed VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR" VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR" + VERSION_DOCS_API_SINCE="$DEFAULT_VERSION_DOCS_API_SINCE" JDK_SOURCE_TARGET_VERSION="$DEFAULT_JDK_SOURCE_TARGET_VERSION" AC_MSG_CHECKING([for version string]) @@ -557,5 +558,6 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], AC_SUBST(VENDOR_VERSION_STRING) AC_SUBST(VERSION_CLASSFILE_MAJOR) AC_SUBST(VERSION_CLASSFILE_MINOR) + AC_SUBST(VERSION_DOCS_API_SINCE) AC_SUBST(JDK_SOURCE_TARGET_VERSION) ]) diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index b8ca7972f76..d1e6cd3b2ff 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -230,6 +230,9 @@ VENDOR_VERSION_STRING := @VENDOR_VERSION_STRING@ VERSION_CLASSFILE_MAJOR := @VERSION_CLASSFILE_MAJOR@ VERSION_CLASSFILE_MINOR := @VERSION_CLASSFILE_MINOR@ +# Version for API docs "new-since" feature +VERSION_DOCS_API_SINCE := @VERSION_DOCS_API_SINCE@ + JDK_SOURCE_TARGET_VERSION := @JDK_SOURCE_TARGET_VERSION@ # Convenience CFLAGS settings for passing version information into native programs. diff --git a/make/conf/version-numbers.conf b/make/conf/version-numbers.conf index 422fc795908..0db8f8f771d 100644 --- a/make/conf/version-numbers.conf +++ b/make/conf/version-numbers.conf @@ -36,6 +36,7 @@ DEFAULT_VERSION_EXTRA3=0 DEFAULT_VERSION_DATE=2021-09-14 DEFAULT_VERSION_CLASSFILE_MAJOR=61 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 +DEFAULT_VERSION_DOCS_API_SINCE=11 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="16 17" DEFAULT_JDK_SOURCE_TARGET_VERSION=17 DEFAULT_PROMOTED_VERSION_PRE=ea diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java index b99d33e4e99..53fa302bb89 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java @@ -142,6 +142,8 @@ public class Contents { public final Content navProperty; public final Content navServices; public final Content nestedClassSummary; + public final Content newAPI; + public final Content newLabel; public final Content noScriptMessage; public final Content openModuleLabel; public final Content openedTo; @@ -287,6 +289,8 @@ public class Contents { navProperty = getContent("doclet.navProperty"); navServices = getContent("doclet.navServices"); nestedClassSummary = getContent("doclet.Nested_Class_Summary"); + newAPI = getContent("doclet.New_API"); + newLabel = getContent("doclet.New_Label"); noScriptMessage = getContent("doclet.No_Script_Message"); openedTo = getContent("doclet.OpenedTo"); openModuleLabel = getContent("doclet.Open_Module"); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java index aa840bd7638..3718a77b847 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java @@ -27,8 +27,11 @@ package jdk.javadoc.internal.doclets.formats.html; import com.sun.source.doctree.DeprecatedTree; import java.util.List; +import java.util.ListIterator; import javax.lang.model.element.Element; + +import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; import jdk.javadoc.internal.doclets.toolkit.Content; @@ -45,18 +48,17 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or * deletion without notice. - * - * @see java.util.List */ public class DeprecatedListWriter extends SummaryListWriter { + private final static String TERMINALLY_DEPRECATED_KEY = "doclet.Terminally_Deprecated_Elements"; + /** * Constructor. * * @param configuration the configuration for this doclet * @param filename the file to be generated */ - public DeprecatedListWriter(HtmlConfiguration configuration, DocPath filename) { super(configuration, filename, PageMode.DEPRECATED, "deprecated elements", configuration.contents.deprecatedAPI, "doclet.Window_Deprecated_List"); @@ -80,17 +82,22 @@ public class DeprecatedListWriter extends SummaryListWriter 1) { + content.add(HtmlTree.SPAN(contents.getContent("doclet.Deprecated_Tabs_Intro")) + .addStyle(HtmlStyle.helpNote)); + } addSummaryAPI(list.getForRemoval(), HtmlIds.FOR_REMOVAL, - "doclet.For_Removal", "doclet.Element", content); + TERMINALLY_DEPRECATED_KEY, "doclet.Element", content); } @Override protected void addExtraIndexLink(DeprecatedAPIListBuilder list, Content target) { if (!list.getForRemoval().isEmpty()) { - addIndexLink(HtmlIds.FOR_REMOVAL, "doclet.For_Removal", target); + addIndexLink(HtmlIds.FOR_REMOVAL, "doclet.Terminally_Deprecated", target); } } + @Override protected void addComments(Element e, Content desc) { List tags = utils.getDeprecatedTrees(e); if (!tags.isEmpty()) { @@ -100,4 +107,28 @@ public class DeprecatedListWriter extends SummaryListWriter releases = configuration.deprecatedAPIListBuilder.releases; + if (!releases.isEmpty()) { + table.setDefaultTab(getTableCaption(headingKey)).setAlwaysShowDefaultTab(true); + ListIterator it = releases.listIterator(releases.size()); + while (it.hasPrevious()) { + String release = it.previous(); + Content tab = TERMINALLY_DEPRECATED_KEY.equals(headingKey) + ? contents.getContent("doclet.Terminally_Deprecated_In_Release", release) + : contents.getContent("doclet.Deprecated_In_Release", release); + table.addTab(tab, + element -> release.equals(utils.getDeprecatedSince(element))); + } + getMainBodyScript().append(table.getScript()); + } + } + + @Override + protected Content getTableCaption(String headingKey) { + Content caption = contents.getContent(headingKey); + return TERMINALLY_DEPRECATED_KEY.equals(headingKey) + ? caption : contents.getContent("doclet.Deprecated_Elements", caption); + } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java index beb347a9ba9..7343ec3a9f5 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java @@ -346,15 +346,6 @@ public class HelpWriter extends HtmlDocletWriter { pageKindsSection.add(section); } - // Deprecated - if (configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.DEPRECATED)) { - section = newHelpSection(contents.deprecatedAPI, PageMode.DEPRECATED, subTOC); - Content deprBody = getContent("doclet.help.deprecated.body", - links.createLink(DocPaths.DEPRECATED_LIST, resources.getText("doclet.Deprecated_API"))); - section.add(HtmlTree.P(deprBody)); - pageKindsSection.add(section); - } - // Preview if (configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.PREVIEW)) { section = newHelpSection(contents.previewAPI, PageMode.PREVIEW, subTOC); @@ -364,6 +355,24 @@ public class HelpWriter extends HtmlDocletWriter { pageKindsSection.add(section); } + // New + if (configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.NEW)) { + section = newHelpSection(contents.newAPI, PageMode.NEW, subTOC); + Content newBody = getContent("doclet.help.new.body", + links.createLink(DocPaths.NEW_LIST, contents.newAPI)); + section.add(HtmlTree.P(newBody)); + pageKindsSection.add(section); + } + + // Deprecated + if (configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.DEPRECATED)) { + section = newHelpSection(contents.deprecatedAPI, PageMode.DEPRECATED, subTOC); + Content deprBody = getContent("doclet.help.deprecated.body", + links.createLink(DocPaths.DEPRECATED_LIST, resources.getText("doclet.Deprecated_API"))); + section.add(HtmlTree.P(deprBody)); + pageKindsSection.add(section); + } + // Constant Field Values if (configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.CONSTANT_VALUES)) { section = newHelpSection(contents.constantsSummaryTitle, PageMode.CONSTANT_VALUES, subTOC); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java index e3a4862dd16..a4596536bc9 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java @@ -60,6 +60,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; +import jdk.javadoc.internal.doclets.toolkit.util.NewAPIBuilder; import jdk.javadoc.internal.doclets.toolkit.util.PreviewAPIListBuilder; /** @@ -128,6 +129,14 @@ public class HtmlConfiguration extends BaseConfiguration { */ protected PreviewAPIListBuilder previewAPIListBuilder; + /** + * The collection of new API items, if any, to be displayed on the new-list page, + * or null if the page should not be generated. + * The page is only generated if the {@code --since} option is used with release + * names matching {@code @since} tags in the documented code. + */ + protected NewAPIBuilder newAPIPageBuilder; + public Contents contents; protected final Messages messages; @@ -146,7 +155,7 @@ public class HtmlConfiguration extends BaseConfiguration { // Note: this should (eventually) be merged with Navigation.PageMode, // which performs a somewhat similar role public enum ConditionalPage { - CONSTANT_VALUES, DEPRECATED, PREVIEW, SERIALIZED_FORM, SYSTEM_PROPERTIES + CONSTANT_VALUES, DEPRECATED, PREVIEW, SERIALIZED_FORM, SYSTEM_PROPERTIES, NEW } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java index 1ff3ce38d53..a1182b55da6 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java @@ -55,6 +55,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; +import jdk.javadoc.internal.doclets.toolkit.util.NewAPIBuilder; import jdk.javadoc.internal.doclets.toolkit.util.PreviewAPIListBuilder; /** @@ -173,18 +174,25 @@ public class HtmlDoclet extends AbstractDoclet { @Override // defined by AbstractDoclet public void generateClassFiles(ClassTree classTree) throws DocletException { - + List since = configuration.getOptions().since(); if (!(configuration.getOptions().noDeprecated() || configuration.getOptions().noDeprecatedList())) { - DeprecatedAPIListBuilder builder = new DeprecatedAPIListBuilder(configuration); - if (!builder.isEmpty()) { - configuration.deprecatedAPIListBuilder = builder; + DeprecatedAPIListBuilder deprecatedBuilder = new DeprecatedAPIListBuilder(configuration, since); + if (!deprecatedBuilder.isEmpty()) { + configuration.deprecatedAPIListBuilder = deprecatedBuilder; configuration.conditionalPages.add(HtmlConfiguration.ConditionalPage.DEPRECATED); } } - PreviewAPIListBuilder builder = new PreviewAPIListBuilder(configuration); - if (!builder.isEmpty()) { - configuration.previewAPIListBuilder = builder; + if (!since.isEmpty()) { + NewAPIBuilder newAPIBuilder = new NewAPIBuilder(configuration, since); + if (!newAPIBuilder.isEmpty()) { + configuration.newAPIPageBuilder = newAPIBuilder; + configuration.conditionalPages.add(HtmlConfiguration.ConditionalPage.NEW); + } + } + PreviewAPIListBuilder previewBuilder = new PreviewAPIListBuilder(configuration); + if (!previewBuilder.isEmpty()) { + configuration.previewAPIListBuilder = previewBuilder; configuration.conditionalPages.add(HtmlConfiguration.ConditionalPage.PREVIEW); } @@ -239,6 +247,10 @@ public class HtmlDoclet extends AbstractDoclet { PreviewListWriter.generate(configuration); } + if (configuration.conditionalPages.contains((HtmlConfiguration.ConditionalPage.NEW))) { + NewAPIListWriter.generate(configuration); + } + if (options.createOverview()) { if (configuration.showModules) { ModuleIndexWriter.generate(configuration); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 151cc6e140a..ae02af052a3 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -2103,7 +2103,8 @@ public class HtmlDocletWriter { String kind = getClass().getSimpleName() .replaceAll("(Writer)?(Impl)?$", "") .replaceAll("AnnotationType", "Class") - .replaceAll("^(Module|Package|Class)$", "$1Declaration"); + .replaceAll("^(Module|Package|Class)$", "$1Declaration") + .replace("API", "Api"); String page = kind.substring(0, 1).toLowerCase(Locale.US) + kind.substring(1) + "Page"; return HtmlStyle.valueOf(page); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java index 1af0a44665a..52ec3b99a24 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java @@ -88,6 +88,7 @@ public class Navigation { HELP, INDEX, MODULE, + NEW, OVERVIEW, PACKAGE, PREVIEW, @@ -171,8 +172,9 @@ public class Navigation { addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.useLabel, options.classUse()); addTreeLink(tree); - addDeprecatedLink(tree); addPreviewLink(tree); + addNewLink(tree); + addDeprecatedLink(tree); addIndexLink(tree); addHelpLink(tree); break; @@ -183,8 +185,9 @@ public class Navigation { addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.useLabel, options.classUse()); addTreeLink(tree); - addDeprecatedLink(tree); addPreviewLink(tree); + addNewLink(tree); + addDeprecatedLink(tree); addIndexLink(tree); addHelpLink(tree); break; @@ -201,8 +204,9 @@ public class Navigation { addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE, contents.treeLabel, "")); } - addDeprecatedLink(tree); addPreviewLink(tree); + addNewLink(tree); + addDeprecatedLink(tree); addIndexLink(tree); addHelpLink(tree); break; @@ -219,8 +223,9 @@ public class Navigation { addContentToTree(tree, links.createLink(DocPaths.PACKAGE_TREE, contents.treeLabel, "")); } - addDeprecatedLink(tree); addPreviewLink(tree); + addNewLink(tree); + addDeprecatedLink(tree); addIndexLink(tree); addHelpLink(tree); break; @@ -242,8 +247,9 @@ public class Navigation { ? links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel) : links.createLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel)); } - addDeprecatedLink(tree); addPreviewLink(tree); + addNewLink(tree); + addDeprecatedLink(tree); addIndexLink(tree); addHelpLink(tree); break; @@ -259,8 +265,9 @@ public class Navigation { addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.useLabel, options.classUse()); addActivePageLink(tree, contents.treeLabel, options.createTree()); - addDeprecatedLink(tree); addPreviewLink(tree); + addNewLink(tree); + addDeprecatedLink(tree); addIndexLink(tree); addHelpLink(tree); break; @@ -268,24 +275,31 @@ public class Navigation { case INDEX: case HELP: case PREVIEW: + case NEW: addOverviewLink(tree); addModuleLink(tree); addPackageLink(tree); addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.useLabel, options.classUse()); addTreeLink(tree); - if (documentedPage == PageMode.DEPRECATED) { - addActivePageLink(tree, contents.deprecatedLabel, - configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.DEPRECATED)); - } else { - addDeprecatedLink(tree); - } if (documentedPage == PageMode.PREVIEW) { addActivePageLink(tree, contents.previewLabel, configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.PREVIEW)); } else { addPreviewLink(tree); } + if (documentedPage == PageMode.NEW) { + addActivePageLink(tree, contents.newLabel, + configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.NEW)); + } else { + addNewLink(tree); + } + if (documentedPage == PageMode.DEPRECATED) { + addActivePageLink(tree, contents.deprecatedLabel, + configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.DEPRECATED)); + } else { + addDeprecatedLink(tree); + } if (documentedPage == PageMode.INDEX) { addActivePageLink(tree, contents.indexLabel, options.createIndex()); } else { @@ -308,8 +322,9 @@ public class Navigation { addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.useLabel, options.classUse()); addTreeLink(tree); - addDeprecatedLink(tree); addPreviewLink(tree); + addNewLink(tree); + addDeprecatedLink(tree); addIndexLink(tree); addHelpLink(tree); break; @@ -320,8 +335,9 @@ public class Navigation { addPageLabel(tree, contents.classLabel, true); addPageLabel(tree, contents.useLabel, options.classUse()); addTreeLink(tree); - addDeprecatedLink(tree); addPreviewLink(tree); + addNewLink(tree); + addDeprecatedLink(tree); addIndexLink(tree); addHelpLink(tree); break; @@ -531,6 +547,13 @@ public class Navigation { } } + private void addNewLink(Content tree) { + if (configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.NEW)) { + tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.NEW_LIST), + contents.newLabel, ""))); + } + } + private void addIndexLink(Content tree) { if (options.createIndex()) { tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve( diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NewAPIListWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NewAPIListWriter.java new file mode 100644 index 00000000000..320ddfeb358 --- /dev/null +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NewAPIListWriter.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.javadoc.internal.doclets.formats.html; + +import javax.lang.model.element.Element; + +import com.sun.source.doctree.DocTree; +import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; +import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; +import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; +import jdk.javadoc.internal.doclets.formats.html.markup.Text; +import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; +import jdk.javadoc.internal.doclets.toolkit.util.DocPath; +import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; +import jdk.javadoc.internal.doclets.toolkit.util.NewAPIBuilder; + +import java.util.List; +import java.util.ListIterator; + +import static com.sun.source.doctree.DocTree.Kind.SINCE; + +/** + * Generates a file containing a list of new API elements with the appropriate links. + * + *

This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + * + */ +public class NewAPIListWriter extends SummaryListWriter { + + /** + * Constructor. + * + * @param configuration the configuration for this doclet + */ + public NewAPIListWriter(NewAPIBuilder builder, HtmlConfiguration configuration, DocPath filename) { + super(configuration, filename, PageMode.NEW, "new elements", + Text.of(getHeading(builder, configuration)), + "doclet.Window_New_List"); + } + + /** + * If the "New API" page is configured this method instantiates a NewAPIListWriter + * and generates the file. + * + * @param configuration the current configuration of the doclet. + * @throws DocFileIOException if there is a problem writing the new API list + */ + public static void generate(HtmlConfiguration configuration) throws DocFileIOException { + if (configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.NEW)) { + NewAPIBuilder builder = configuration.newAPIPageBuilder; + NewAPIListWriter writer = new NewAPIListWriter(builder, configuration, DocPaths.NEW_LIST); + writer.generateSummaryListFile(builder); + } + } + + @Override + protected void addExtraSection(NewAPIBuilder list, Content content) { + if (list.releases.size() > 1) { + content.add(HtmlTree.SPAN(contents.getContent("doclet.New_Tabs_Intro")) + .addStyle(HtmlStyle.helpNote)); + } + } + + @Override + protected void addTableTabs(Table table, String headingKey) { + List releases = configuration.newAPIPageBuilder.releases; + if (!releases.isEmpty()) { + table.setDefaultTab(getTableCaption(headingKey)).setAlwaysShowDefaultTab(true); + ListIterator it = releases.listIterator(releases.size()); + while (it.hasPrevious()) { + String release = it.previous(); + table.addTab( + releases.size() == 1 + ? getTableCaption(headingKey) + : contents.getContent( + "doclet.New_Elements_Added_In_Release", release), + element -> { + if (!utils.hasDocCommentTree(element)) { + return false; + } + List since = utils.getBlockTags(element, SINCE); + if (since.isEmpty()) { + return false; + } + CommentHelper ch = utils.getCommentHelper(element); + return since.stream().anyMatch(tree -> release.equals(ch.getBody(tree).toString())); + }); + } + getMainBodyScript().append(table.getScript()); + } + } + + @Override + protected void addComments(Element e, Content desc) { + addSummaryComment(e, desc); + } + + @Override + protected Content getTableCaption(String headingKey) { + return contents.getContent("doclet.New_Elements", super.getTableCaption(headingKey)); + } + + private static String getHeading(NewAPIBuilder builder, HtmlConfiguration configuration) { + String label = configuration.getOptions().sinceLabel(); + return label == null ? configuration.docResources.getText("doclet.New_API") : label; + } +} diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PreviewListWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PreviewListWriter.java index 667e9266b68..0d2aac93305 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PreviewListWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PreviewListWriter.java @@ -75,8 +75,7 @@ public class PreviewListWriter extends SummaryListWriter if (configuration.conditionalPages.contains(HtmlConfiguration.ConditionalPage.PREVIEW)) { DocPath filename = DocPaths.PREVIEW_LIST; PreviewListWriter depr = new PreviewListWriter(configuration, filename); - depr.generateSummaryListFile( - new PreviewAPIListBuilder(configuration)); + depr.generateSummaryListFile(configuration.previewAPIListBuilder); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SummaryListWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SummaryListWriter.java index e48c614ba22..6c0a03f2d52 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SummaryListWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SummaryListWriter.java @@ -53,7 +53,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.SummaryAPIListBuilder.SummaryEl * This code and its internal interfaces are subject to change or * deletion without notice. */ -public abstract class SummaryListWriter extends SubWriterHolderWriter { +public class SummaryListWriter extends SubWriterHolderWriter { private String getHeadingKey(SummaryElementKind kind) { return switch (kind) { @@ -208,12 +208,12 @@ public abstract class SummaryListWriter extends TableHeader tableHeader = new TableHeader( contents.getContent(headerKey), contents.descriptionLabel); - Content caption = contents.getContent(headingKey); Table table = new Table(HtmlStyle.summaryTable) - .setCaption(caption) + .setCaption(getTableCaption(headingKey)) .setHeader(tableHeader) .setId(id) .setColumnStyles(HtmlStyle.colSummaryItemName, HtmlStyle.colLast); + addTableTabs(table, headingKey); for (Element e : apiList) { Content link; switch (e.getKind()) { @@ -230,7 +230,7 @@ public abstract class SummaryListWriter extends } Content desc = new ContentBuilder(); addComments(e, desc); - table.addRow(link, desc); + table.addRow(e, link, desc); } // note: singleton list contentTree.add(HtmlTree.UL(HtmlStyle.blockList, HtmlTree.LI(table))); @@ -243,7 +243,8 @@ public abstract class SummaryListWriter extends * @param e the element for which the summary text should be added * @param desc the target to which the text should be added */ - protected abstract void addComments(Element e, Content desc); + protected void addComments(Element e, Content desc) { + } protected Content getSummaryLink(Element e) { AbstractMemberWriter writer = switch (e.getKind()) { @@ -277,4 +278,22 @@ public abstract class SummaryListWriter extends */ protected void addExtraIndexLink(L list, Content target) { } + + /** + * Returns the caption for the table with the given {@code headingKey}. + * + * @param headingKey the key for the table heading + * @return the table caption + */ + protected Content getTableCaption(String headingKey) { + return contents.getContent(headingKey); + } + + /** + * Allow subclasses to add extra tabs to the element tables. + * + * @param table the element table + * @param headingKey the key for the caption (default tab) + */ + protected void addTableTabs(Table table, String headingKey) {} } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java index 8c38a518a51..25f7e98f4f2 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java @@ -87,6 +87,7 @@ public class Table extends Content { private List stripedStyles = Arrays.asList(HtmlStyle.evenRowColor, HtmlStyle.oddRowColor); private final List bodyRows; private HtmlId id; + private boolean alwaysShowDefaultTab = false; /** * Creates a builder for an HTML element representing a table. @@ -142,6 +143,16 @@ public class Table extends Content { return this; } + /** + * Sets whether to display the default tab even if tabs are empty or only contain a single tab. + * @param showDefaultTab true if default tab should always be shown + * @return this object + */ + public Table setAlwaysShowDefaultTab(boolean showDefaultTab) { + this.alwaysShowDefaultTab = showDefaultTab; + return this; + } + /** * Sets the name of the styles used to display the tabs. * @@ -376,7 +387,7 @@ public class Table extends Content { }; HtmlTree table = new HtmlTree(TagName.DIV).setStyle(tableStyle).addStyle(columnStyle); - if (tabMap == null || tabs.size() == 1) { + if ((tabMap == null || tabs.size() == 1) && !alwaysShowDefaultTab) { if (tabMap == null) { main.add(caption); } else { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java index 940924f1bea..f2bad722824 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java @@ -719,6 +719,11 @@ public enum HtmlStyle { */ deprecatedListPage, + /** + * The class of the {@code body} element for the page listing any deprecated items. + */ + deprecatedInReleasePage, + /** * The class of the {@code body} element for a "doc-file" page.. */ @@ -749,6 +754,11 @@ public enum HtmlStyle { */ moduleIndexPage, + /** + * The class of the {@code body} element for the page listing new API elements. + */ + newApiListPage, + /** * The class of the {@code body} element for a package-declaration page. */ diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties index c53e8f2df76..89d192303c3 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties @@ -81,6 +81,7 @@ doclet.Skip_navigation_links=Skip navigation links doclet.Navigation=Navigation doclet.navDeprecated=Deprecated doclet.Window_Deprecated_List=Deprecated List +doclet.Window_New_List=New API List doclet.Window_Preview_List=Preview List doclet.Overrides=Overrides: doclet.in_class=in class @@ -104,10 +105,27 @@ doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1 doclet.see.nested_link=Tag {0}: nested link doclet.tag.invalid_usage=invalid usage of tag {0} doclet.Deprecated_API=Deprecated API +doclet.Deprecated_Elements=Deprecated {0} +doclet.Deprecated_In_Release=Deprecated in {0} +doclet.Deprecated_Tabs_Intro=(The leftmost tab "Deprecated ..." indicates all the \ + deprecated elements, regardless of the releases in which they were deprecated. \ + Each of the other tabs "Deprecated in ..." indicates the elements deprecated \ + in a specific release.) +doclet.New_API=New API +doclet.New_Elements=New {0} +doclet.New_Elements_Added_In_Release=Added in {0} +doclet.New_Label=New +doclet.New_Tabs_Intro=(The leftmost tab "New ..." indicates all the new elements, \ + regardless of the releases in which they were added. Each of the other tabs \ + "Added in ..." indicates the new elements added in a specific release. \ + Any element shown under the leftmost tab is also shown under one of the \ + righthand tabs.) doclet.Preview_API=Preview API doclet.Preview_Label=Preview doclet.Preview_Mark=PREVIEW -doclet.For_Removal=For Removal +doclet.Terminally_Deprecated=Terminally Deprecated +doclet.Terminally_Deprecated_Elements=Terminally Deprecated Elements +doclet.Terminally_Deprecated_In_Release=Terminally Deprecated in {0} doclet.Annotation_Types=Annotation Types doclet.Annotation_Interfaces=Annotation Interfaces doclet.Annotation_Type_Members=Annotation Type Elements @@ -245,6 +263,8 @@ doclet.help.deprecated.body=\ doclet.help.preview.body=\ The {0} page lists all of the Preview APIs. \ Preview APIs may be removed in future implementations. +doclet.help.new.body=\ + The {0} page lists APIs that have been added in recent releases. doclet.help.index.head=\ Index # 0: link to Index page; 1: list of links to pages @@ -496,6 +516,16 @@ doclet.usage.nooverview.description=\ doclet.usage.serialwarn.description=\ Generate warning about @serial tag +doclet.usage.since.parameters=\ + (,)* +doclet.usage.since.description=\ + Document new and deprecated API in the specified releases + +doclet.usage.since-label.parameters=\ + +doclet.usage.since-label.description=\ + Provide text to use in the heading of the "New API" page + doclet.usage.tag.parameters=\ ::

doclet.usage.tag.description=\ diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseOptions.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseOptions.java index 1380c432390..492ff91a2fe 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseOptions.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseOptions.java @@ -32,6 +32,7 @@ import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; @@ -248,6 +249,18 @@ public abstract class BaseOptions { */ private boolean showVersion = false; + /** + * Argument for command line option {@code --since}. + * Specifies a list of release names for which to document API changes. + */ + private List since = List.of(); + + /** + * Argument for command line option {@code --since-label}. + * Specifies custom text to use as heading of New API page. + */ + private String sinceLabel; + /** * Argument for command-line option {@code -sourcetab}. * The specified amount of space between tab stops. @@ -476,6 +489,22 @@ public abstract class BaseOptions { } }, + new Option(resources, "--since", 1) { + @Override + public boolean process(String opt, List args) { + since = Arrays.stream(args.get(0).split(",")).map(String::trim).toList(); + return true; + } + }, + + new Option(resources, "--since-label", 1) { + @Override + public boolean process(String opt, List args) { + sinceLabel = args.get(0); + return true; + } + }, + new Option(resources, "-sourcetab", 1) { @Override public boolean process(String opt, List args) { @@ -892,6 +921,20 @@ public abstract class BaseOptions { return showVersion; } + /** + * Arguments for command line option {@code --since}. + */ + public List since() { + return Collections.unmodifiableList(since); + } + + /** + * Arguments for command line option {@code --since-label}. + */ + public String sinceLabel() { + return sinceLabel; + } + /** * Argument for command-line option {@code -sourcetab}. * The specified amount of space between tab stops. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java index d96cca5fe80..94710452653 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java @@ -40,15 +40,20 @@ import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; * deletion without notice. */ public class DeprecatedAPIListBuilder extends SummaryAPIListBuilder { + private SortedSet forRemoval; + public final List releases; /** * Constructor. * * @param configuration the current configuration of the doclet + * @param releases list of releases */ - public DeprecatedAPIListBuilder(BaseConfiguration configuration) { + public DeprecatedAPIListBuilder(BaseConfiguration configuration, List releases) { super(configuration, configuration.utils::isDeprecated); + this.releases = releases; + buildSummaryAPIInfo(); } public SortedSet getForRemoval() { @@ -64,5 +69,4 @@ public class DeprecatedAPIListBuilder extends SummaryAPIListBuilder { getForRemoval().add(e); } } - } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java index 30f46c99df7..42f2c97c49f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java @@ -142,9 +142,12 @@ public class DocPaths { /** The name of the file for the package usage info. */ public static final DocPath PACKAGE_USE = DocPath.create("package-use.html"); - /** The name of the fie for preview elements. */ + /** The name of the file for preview elements. */ public static final DocPath PREVIEW_LIST = DocPath.create("preview-list.html"); + /** The name of the file for new elements. */ + public static final DocPath NEW_LIST = DocPath.create("new-list.html"); + /** The name of the file for all system properties. */ public static final DocPath SYSTEM_PROPERTIES = DocPath.create("system-properties.html"); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/NewAPIBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/NewAPIBuilder.java new file mode 100644 index 00000000000..73123418d6d --- /dev/null +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/NewAPIBuilder.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.javadoc.internal.doclets.toolkit.util; + +import com.sun.source.doctree.DocTree; +import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; + +import javax.lang.model.element.Element; +import java.util.List; + + +import static com.sun.source.doctree.DocTree.Kind.SINCE; + +/** + * Build list of all the packages, classes, constructors, fields and methods + * that were added in one of the releases specified by the {@code --since} + * option. The release names must exactly match the names used in the javadoc + * {@code @since} tags of the respective elements. + * + *

This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +public class NewAPIBuilder extends SummaryAPIListBuilder { + + public final List releases; + + public NewAPIBuilder(BaseConfiguration configuration, List releases) { + super(configuration, element -> isNewAPI(element, configuration.utils, releases)); + this.releases = releases; + buildSummaryAPIInfo(); + } + + private static boolean isNewAPI(Element e, Utils utils, List releases) { + if (!utils.hasDocCommentTree(e)) { + return false; + } + List since = utils.getBlockTags(e, SINCE); + if (since.isEmpty()) { + return false; + } + CommentHelper ch = utils.getCommentHelper(e); + return since.stream().anyMatch(tree -> releases.contains(ch.getBody(tree).toString())); + } +} diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PreviewAPIListBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PreviewAPIListBuilder.java index 6ca4c01ca30..db7ca4028ca 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PreviewAPIListBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PreviewAPIListBuilder.java @@ -44,5 +44,6 @@ public class PreviewAPIListBuilder extends SummaryAPIListBuilder { */ public PreviewAPIListBuilder(BaseConfiguration configuration) { super(configuration, e -> configuration.utils.isPreviewAPI(e)); + buildSummaryAPIInfo(); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/SummaryAPIListBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/SummaryAPIListBuilder.java index 9a89f881036..05a35dee4d8 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/SummaryAPIListBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/SummaryAPIListBuilder.java @@ -84,7 +84,6 @@ public class SummaryAPIListBuilder { for (SummaryElementKind kind : SummaryElementKind.values()) { summaryMap.put(kind, createSummarySet()); } - buildSummaryAPIInfo(); } public boolean isEmpty() { @@ -96,22 +95,22 @@ public class SummaryAPIListBuilder { * Build separate lists for summary modules, packages, classes, constructors, * methods and fields. */ - private void buildSummaryAPIInfo() { + protected void buildSummaryAPIInfo() { SortedSet modules = configuration.modules; SortedSet mset = summaryMap.get(SummaryElementKind.MODULE); for (Element me : modules) { if (belongsToSummary.test(me)) { mset.add(me); + handleElement(me); } - handleElement(me); } SortedSet packages = configuration.packages; SortedSet pset = summaryMap.get(SummaryElementKind.PACKAGE); for (Element pe : packages) { if (belongsToSummary.test(pe)) { pset.add(pe); + handleElement(pe); } - handleElement(pe); } for (Element e : configuration.getIncludedTypeElements()) { TypeElement te = (TypeElement)e; @@ -145,8 +144,8 @@ public class SummaryAPIListBuilder { eset.add(e); } } + handleElement(te); } - handleElement(te); composeSummaryList(summaryMap.get(SummaryElementKind.FIELD), utils.getFields(te)); composeSummaryList(summaryMap.get(SummaryElementKind.METHOD), @@ -184,8 +183,8 @@ public class SummaryAPIListBuilder { for (Element member : members) { if (belongsToSummary.test(member)) { sset.add(member); + handleElement(member); } - handleElement(member); } } @@ -209,7 +208,7 @@ public class SummaryAPIListBuilder { } /** - * Additional extra processing of an analyzed element. + * Additional extra processing of an included element. * * @param e element to process */ diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java index 24906467c63..36585cd33c8 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java @@ -1503,12 +1503,30 @@ public class Utils { } /** - * Return true if the given Element is deprecated for removal. + * Returns true if the given Element is deprecated for removal. * * @param e the Element to check. * @return true if the given Element is deprecated for removal. */ public boolean isDeprecatedForRemoval(Element e) { + Object forRemoval = getDeprecatedElement(e, "forRemoval"); + return forRemoval != null && (boolean) forRemoval; + } + + /** + * Returns the value of the {@code Deprecated.since} element if it is set on the given Element. + * + * @param e the Element to check. + * @return the Deprecated.since value for e, or null. + */ + public String getDeprecatedSince(Element e) { + return (String) getDeprecatedElement(e, "since"); + } + + /** + * Returns the Deprecated annotation element value of the given element, or null. + */ + private Object getDeprecatedElement(Element e, String elementName) { List annotationList = e.getAnnotationMirrors(); JavacTypes jctypes = ((DocEnvImpl) configuration.docEnv).toolEnv.typeutils; for (AnnotationMirror anno : annotationList) { @@ -1516,14 +1534,14 @@ public class Utils { Map pairs = anno.getElementValues(); if (!pairs.isEmpty()) { for (ExecutableElement element : pairs.keySet()) { - if (element.getSimpleName().contentEquals("forRemoval")) { - return Boolean.parseBoolean((pairs.get(element)).toString()); + if (element.getSimpleName().contentEquals(elementName)) { + return (pairs.get(element)).getValue(); } } } } } - return false; + return null; } /** diff --git a/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java b/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java index 965a35c7968..4f8d61b767b 100644 --- a/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java +++ b/test/langtools/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java @@ -267,7 +267,7 @@ public class TestDeprecatedDocs extends JavadocTester { checkOutput("deprecated-list.html", true, """

""", """
-
For Removal
+
Terminally Deprecated Elements
Element
Description
""", """
-
Enum Classes
+
Deprecated Enum Classes
Enum Class
Description
@@ -297,7 +297,7 @@ public class TestDeprecatedDocs extends JavadocTester {
""", """
-
Exceptions
+
Deprecated Exceptions
Exceptions
Description
@@ -307,7 +307,7 @@ public class TestDeprecatedDocs extends JavadocTester {
""", """
-
Fields
+
Deprecated Fields
Field
Description
@@ -337,7 +337,7 @@ public class TestDeprecatedDocs extends JavadocTester {
""", """
-
Methods
+
Deprecated Methods
Method
Description
@@ -365,7 +365,7 @@ public class TestDeprecatedDocs extends JavadocTester {
""", """
-
Constructors
+
Deprecated Constructors
Constructor
Description
diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java b/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java index 4374ac83b92..32c23d6bf42 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,7 +85,7 @@ public class TestHtmlTableStyles extends JavadocTester { checkOutput("deprecated-list.html", true, """
-
Methods
+
Deprecated Methods
"""); checkOutput("constant-values.html", true, diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java b/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java index d8ee249eff3..0187764a134 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java @@ -423,9 +423,9 @@ public class TestHtmlTableTags extends JavadocTester { // Deprecated checkOutput("deprecated-list.html", true, """ -
Fields
""", +
Deprecated Fields
""", """ -
Methods
"""); +
Deprecated Methods
"""); // Constant values checkOutput("constant-values.html", true, diff --git a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java index 4817cecb7b2..8aa57c39db9 100644 --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java @@ -1111,7 +1111,7 @@ public class TestModules extends JavadocTester { checkOutput("deprecated-list.html", found, """ """, """ diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/TestNewApiList.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/TestNewApiList.java new file mode 100644 index 00000000000..d079715addb --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/TestNewApiList.java @@ -0,0 +1,884 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8263468 + * @summary New page for "recent" new API + * @library ../../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build javadoc.tester.* + * @run main TestNewApiList + */ + +import javadoc.tester.JavadocTester; + +/** + * Test --since option and "New API" list. + */ +public class TestNewApiList extends JavadocTester { + + public static void main(String... args) throws Exception { + TestNewApiList test = new TestNewApiList(); + test.runTests(); + } + + @Test + public void testMultiRelease() throws Exception { + javadoc("-d", "out-multi", + "--no-platform-links", + "--module-source-path", testSrc, + "--since", "0.9,v1.0,1.2,2.0b,3.2,5", + "--since-label", "New API in recent releases", + "--module", "mdl", + "pkg"); + checkExit(Exit.OK); + checkMultiReleaseContents(); + checkMultiReleaseNewElements(); + checkMultiReleaseDeprecatedElements(); + } + + @Test + public void testSingleRelease() throws Exception { + javadoc("-d", "out-single", + "--no-platform-links", + "--module-source-path", testSrc, + "--since", "5", + "--module", "mdl", + "pkg"); + checkExit(Exit.OK); + checkSingleReleaseContents(); + checkSingleReleaseNewElements(); + checkSingleReleaseDeprecatedElements(); + } + + @Test + public void testPackage() throws Exception { + javadoc("-d", "out-package", + "--no-platform-links", + "-sourcepath", testSrc, + "--since", "1.2,2.0b,3.2,5,6", + "pkg"); + checkExit(Exit.OK); + checkPackageContents(); + checkPackageNewElements(); + checkPackageDeprecatedElements(); + } + + @Test + public void testNoList() throws Exception { + javadoc("-d", "out-none", + "--no-platform-links", + "--module-source-path", testSrc, + "--since", "foo,bar", + "--since-label", "New API in foo and bar", + "--module", "mdl", + "pkg"); + checkExit(Exit.OK); + checkFiles(false, "new-list.html"); + } + + private void checkMultiReleaseContents() { + checkOutput("new-list.html", true, + """ +

New API in recent releases

+

Contents

+ +
+ (The leftmost tab "New ..." indicates all the new elements, \ + regardless of the releases in which they were added. Each of the other tabs "Added i\ + n ..." indicates the new elements added in a specific release. Any element shown und\ + er the leftmost tab is also shown under one of the righthand tabs.)"""); + } + + private void checkMultiReleaseNewElements() { + checkOutput("new-list.html", true, + """ +
+
+
+
+
Module
+
Description
+ +
+
Module mdl.
+
""", + """ +
+
+
+
+
Package
+
Description
+ +
+
Package pkg.
+
""", + """ +
+
+
+
+
Interface
+
Description
+ +
+
Test interface.
+
""", + """ +
+
+
+
+
Class
+
Description
+ +
+
TestClass declaration.
+
""", + """ +
+
+
+
+
Enum Class
+
Description
+ +
+
Test enum class.
+
""", + """ +
+
+
+
+
Exceptions
+
Description
+ +
+
Test exception class.
+
""", + """ +
+
+
+
+
Errors
+
Description
+ +
+
Test error class.
+
""", + """ +
+
+
+
+
Record Class
+
Description
+ +
+
Test record.
+
""", + """ +
+
+
+
+
Annotation Interface
+
Description
+ +
+
An annotation interface.
+
""", + """ +
+
+
+
+
Field
+
Description
+ +
+
TestClass field.
+
+ +
+
Test error field.
+
+ +
+
Exception field.
+
+ +
+
Test interface field.
+
""", + """ +
+
+
+
+
Method
+
Description
+ +
+
Optional annotation interface element.
+
+ +
+
Required annotation interface element.
+
+ +
+
TestClass method.
+
+ +
+
TestClass overloaded method.
+
+ +
+
Test error method.
+
+ +
+
Exception method.
+
+ +
+
Interface method.
+
+ +
+
Interface method.
+
+ +
+
Test record getter.
+
""", + """ +
+
+
+
+
Constructor
+
Description
+ +
+
TestClass constructor.
+
+ +
+
TestClass constructor.
+
+
+
+
Test error constructor.
+
+ +
+
Exception constructor.
+
""", + """ +
+
+
+
+
Enum Constant
+
Description
+
<\ + a href="mdl/pkg/TestEnum.html#DEPRECATED">pkg.TestEnum.DEPRECATED
+
+
Deprecated.
+
+
pkg.TestEnum.ONE
+
+
One.
+
+
<\ + a href="mdl/pkg/TestEnum.html#THREE">pkg.TestEnum.THREE
+
+
Three.
+
+
pkg.TestEnum.TWO
+
+
Two.
+
""", + """ +
+
+
+
+
Annotation Interface Element
+
Description
+ +
+
Optional annotation interface element.
+
+ +
+
Required annotation interface element.
+
"""); + } + + private void checkMultiReleaseDeprecatedElements() { + checkOutput("deprecated-list.html", true, + """ +
+
+
+
+
Element
+
Description
+ +
+
""", + """ +
+
+
+
+
Method
+
Description
+ +
+
""", + """ +
+
+
+
+
Constructor
+
Description
+ +
+
""", + """ +
+
+
+
+
Enum Constant
+
Description
+
<\ + a href="mdl/pkg/TestEnum.html#DEPRECATED">pkg.TestEnum.DEPRECATED
+
+
""", + """ +
+
+
+
+
Annotation Interface Element
+
Description
+ +
+
"""); + } + + private void checkSingleReleaseContents() { + checkOutput("new-list.html", true, + """ +

New API

+

Contents

+ +
+
    """); + } + + private void checkSingleReleaseNewElements() { + checkOutput("new-list.html", true, + """ +
    +
    +
    +
    +
    Method
    +
    Description
    + +
    +
    TestClass overloaded method.
    +
    + +
    +
    Test record getter.
    +
    """, + """ +
    +
    +
    +
    +
    Constructor
    +
    Description
    + +
    +
    Test error constructor.
    +
    + +
    +
    Exception constructor.
    +
    """); + } + + private void checkSingleReleaseDeprecatedElements() { + checkOutput("deprecated-list.html", true, + """ +

    Deprecated API

    +

    Contents

    + +
    +
      """, + """ +
      +
      +
      +
      +
      Element
      +
      Description
      + +
      +
      """, + """ +
      +
      +
      +
      +
      Method
      +
      Description
      + +
      +
      """, + """ +
      +
      +
      +
      +
      Constructor
      +
      Description
      + +
      +
      """); + } + + private void checkPackageContents() { + checkOutput("new-list.html", true, + """ +

      New API

      +

      Contents

      + +
      + (The leftmost tab "New ..." indicates all the new elements, \ + regardless of the releases in which they were added. Each of the other tabs "Added i\ + n ..." indicates the new elements added in a specific release. Any element shown und\ + er the leftmost tab is also shown under one of the righthand tabs.)"""); + } + + private void checkPackageNewElements() { + checkOutput("new-list.html", true, + """ +
      +
      +
      +
      +
      Class
      +
      Description
      + +
      +
      TestClass declaration.
      +
      """, + """ +
      +
      +
      +
      +
      Field
      +
      Description
      + +
      +
      TestClass field.
      +
      """, + """ +
      +
      +
      +
      +
      Method
      +
      Description
      + +
      +
      TestClass method.
      +
      + +
      +
      TestClass overloaded method.
      +
      + +
      +
      TestClass overloaded method.
      +
      """, + """ +
      +
      +
      +
      +
      Constructor
      +
      Description
      + +
      +
      TestClass constructor.
      +
      + +
      +
      TestClass constructor.
      +
      """); + } + + private void checkPackageDeprecatedElements() { + checkOutput("deprecated-list.html", true, + """ +

      Deprecated API

      +

      Contents

      + +
      + (The leftmost tab "Deprecated ..." indicates all the depreca\ + ted elements, regardless of the releases in which they were deprecated. Each of the \ + other tabs "Deprecated in ..." indicates the elements deprecated in a specific relea\ + se.) + """, + """ +
      +
      +
      +
      +
      Constructor
      +
      Description
      + +
      +
      """); + } +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/module-info.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/module-info.java new file mode 100644 index 00000000000..5a5fdb016f0 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/module-info.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Module mdl. + * @since 3.2 + */ +module mdl { + exports pkg; +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestAnnotation.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestAnnotation.java new file mode 100644 index 00000000000..6aa2a8ada2b --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestAnnotation.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +import java.lang.annotation.Documented; + +/** + * An annotation interface. + * @since 2.0b + */ +@Documented public @interface TestAnnotation { + + /** + * Optional annotation interface element. + * @since 3.2 + */ + String optional() default "unknown"; + + /** + * Required annotation interface element. + * @since 2.0b + */ + @Deprecated(forRemoval=true,since="5") + int required(); + + /** + * @since 6 + */ + int field = 0; +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestClass.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestClass.java new file mode 100644 index 00000000000..0a56d1bf6ae --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestClass.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +/** + * TestClass declaration. + * @since 1.2 + */ +public class TestClass { + + /** + * TestClass field. + * @since 1.2 + */ + public int field; + + /** + * TestClass constructor. + * @since 2.0b + */ + @Deprecated(since="5") + public TestClass() {} + + /** + * TestClass constructor. + * @since 3.2 + */ + public TestClass(String s) {} + + /** + * TestClass method. + * @since 2.0b + */ + public void method() {} + + /** + * TestClass overloaded method. + * @since 5 + */ + public void overloadedMethod(String s) {} + + /** + * TestClass overloaded method. + * @since 6 + */ + public void overloadedMethod(int i) {} +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestEnum.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestEnum.java new file mode 100644 index 00000000000..8b74c2fd921 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestEnum.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +/** + * Test enum class. + * @since 0.9 + */ +public enum TestEnum { + + /** + * One. + * @since 0.9 + */ + ONE, + /** + * Two. + * @since v1.0 + */ + TWO, + /** + * Three. + * @since 1.2 + */ + THREE, + /** + * Deprecated. + * @since 3.2 + */ + @Deprecated(since="5") + DEPRECATED; +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestError.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestError.java new file mode 100644 index 00000000000..397476e80fd --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestError.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +/** + * Test error class. + * @since 2.0b + */ +public class TestError extends Error { + + /** + * Test error field. + * @since v1.0 + */ + public int field; + + /** + * Test error constructor. + * @since 5 + */ + public TestError() {} + + /** + * Test error method. + * @since 3.2 + */ + public void method() {} +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestException.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestException.java new file mode 100644 index 00000000000..dae34c379b1 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestException.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +/** + * Test exception class. + * @since 0.9 + */ +public class TestException extends Exception { + + /** + * Exception field. + * @since 3.2 + */ + public int field; + + /** + * Exception constructor. + * @since 5 + */ + public TestException() {} + + /** + * Exception method. + * @since 1.2 + */ + public void method() {} +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestInterface.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestInterface.java new file mode 100644 index 00000000000..c551d7363b6 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +/** + * Test interface. + * @since 0.9 + */ +public interface TestInterface { + + /** + * Test interface field. + * @since 2.0b + */ + int field = 1; + + /** + * Interface method. + * @since v1.0 + */ + void method1(); + + /** + * Interface method. + * @since 3.2 + */ + void method2(Class c); +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestRecord.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestRecord.java new file mode 100644 index 00000000000..7e334fc34eb --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/TestRecord.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +/** + * Test record. + * @since 3.2 + */ +public record TestRecord(int x, int y) { + + /** + * Test record getter. + * @return x + * @since 5 + */ + @Override + public int x() { + return x; + } +} diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/package-info.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/package-info.java new file mode 100644 index 00000000000..471080034fc --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/mdl/pkg/package-info.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Package pkg. + * @since v1.0 + */ +package pkg; \ No newline at end of file diff --git a/test/langtools/jdk/javadoc/doclet/testNewApiList/pkg/TestClass.java b/test/langtools/jdk/javadoc/doclet/testNewApiList/pkg/TestClass.java new file mode 100644 index 00000000000..0a56d1bf6ae --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testNewApiList/pkg/TestClass.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +/** + * TestClass declaration. + * @since 1.2 + */ +public class TestClass { + + /** + * TestClass field. + * @since 1.2 + */ + public int field; + + /** + * TestClass constructor. + * @since 2.0b + */ + @Deprecated(since="5") + public TestClass() {} + + /** + * TestClass constructor. + * @since 3.2 + */ + public TestClass(String s) {} + + /** + * TestClass method. + * @since 2.0b + */ + public void method() {} + + /** + * TestClass overloaded method. + * @since 5 + */ + public void overloadedMethod(String s) {} + + /** + * TestClass overloaded method. + * @since 6 + */ + public void overloadedMethod(int i) {} +} diff --git a/test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java b/test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java index 8c59010c207..01f061ae23a 100644 --- a/test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java +++ b/test/langtools/jdk/javadoc/doclet/testRecordTypes/TestRecordTypes.java @@ -520,7 +520,7 @@ public class TestRecordTypes extends JavadocTester {
    """, """
    -
    Record Classes
    +
    Deprecated Record Classes
    Record Class
    Description
    @@ -552,7 +552,7 @@ public class TestRecordTypes extends JavadocTester {
""", """
-
Methods
+
Deprecated Methods
Method
Description