--- old/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java 2020-01-21 10:50:46.379545980 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java 2020-01-21 10:50:46.059531839 -0800 @@ -85,7 +85,7 @@ } @Override - public Set getSupportedOptions() { + public Set getSupportedOptions() { return htmlDoclet.getSupportedOptions(); } --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java 2020-01-21 10:50:47.147579914 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java 2020-01-21 10:50:46.827565774 -0800 @@ -73,6 +73,7 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter { protected final HtmlConfiguration configuration; + protected final HtmlOptions options; protected final Utils utils; protected final SubWriterHolderWriter writer; protected final Contents contents; @@ -80,14 +81,11 @@ protected final Links links; protected final TypeElement typeElement; - public final boolean nodepr; - - protected boolean printedSummaryHeader = false; public AbstractMemberWriter(SubWriterHolderWriter writer, TypeElement typeElement) { this.configuration = writer.configuration; + this.options = configuration.getOptions(); this.writer = writer; - this.nodepr = configuration.nodeprecated; this.typeElement = typeElement; this.utils = configuration.utils; this.contents = configuration.contents; @@ -380,7 +378,7 @@ } protected void serialWarning(Element e, String key, String a1, String a2) { - if (configuration.serialwarn) { + if (options.serialWarn) { configuration.messages.warning(e, key, a1, a2); } } @@ -598,7 +596,7 @@ // Name HtmlTree nameSpan = new HtmlTree(HtmlTag.SPAN); nameSpan.setStyle(HtmlStyle.memberName); - if (configuration.linksource) { + if (options.linkSource) { Content name = new StringContent(name(element)); writer.addSrcLink(element, name, nameSpan); } else { --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java 2020-01-21 10:50:47.931614556 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractOverviewIndexWriter.java 2020-01-21 10:50:47.607600239 -0800 @@ -141,7 +141,7 @@ .setFooter(footer) .toContent()); printHtmlDocument( - configuration.metakeywords.getOverviewMetaKeywords(title, configuration.doctitle), + configuration.metakeywords.getOverviewMetaKeywords(title, configuration.getOptions().docTitle), description, body); } @@ -158,8 +158,9 @@ * @param body the document tree to which the title will be added */ protected void addConfigurationTitle(Content body) { - if (configuration.doctitle.length() > 0) { - Content title = new RawHtml(configuration.doctitle); + String doctitle = configuration.getOptions().docTitle; + if (doctitle.length() > 0) { + Content title = new RawHtml(doctitle); Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.title, title); Content div = HtmlTree.DIV(HtmlStyle.header, heading); --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java 2020-01-21 10:50:48.719649375 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java 2020-01-21 10:50:48.395635058 -0800 @@ -113,7 +113,7 @@ .setHeader(new TableHeader(contents.packageLabel, contents.descriptionLabel)) .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast); for (PackageElement pkg : configuration.packages) { - if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { + if (!(configuration.getOptions().noDeprecated && utils.isDeprecated(pkg))) { Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg)); Content summaryContent = new ContentBuilder(); addSummaryComment(pkg, summaryContent); --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java 2020-01-21 10:50:49.495683663 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java 2020-01-21 10:50:49.171669346 -0800 @@ -187,7 +187,7 @@ LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType); Content annotationName = new StringContent(utils.getSimpleName(annotationType)); Content parameterLinks = getTypeParameterLinks(linkInfo); - if (configuration.linksource) { + if (configuration.getOptions().linkSource) { addSrcLink(annotationType, annotationName, pre); pre.add(parameterLinks); } else { @@ -203,7 +203,7 @@ */ @Override public void addAnnotationTypeDescription(Content annotationInfoTree) { - if (!configuration.nocomment) { + if (!configuration.getOptions().noComment) { if (!utils.getFullBody(annotationType).isEmpty()) { addInlineComment(annotationType, annotationInfoTree); } @@ -215,7 +215,7 @@ */ @Override public void addAnnotationTypeTagInfo(Content annotationInfoTree) { - if (!configuration.nocomment) { + if (!configuration.getOptions().noComment) { addTagsInfo(annotationType, annotationInfoTree); } } --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java 2020-01-21 10:50:50.275718128 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java 2020-01-21 10:50:49.951703812 -0800 @@ -54,6 +54,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.Utils; /** @@ -158,19 +159,21 @@ */ public static void generate(HtmlConfiguration configuration, ClassTree classtree) throws DocFileIOException { ClassUseMapper mapper = new ClassUseMapper(configuration, classtree); + boolean nodeprecated = configuration.getOptions().noDeprecated; + Utils utils = configuration.utils; for (TypeElement aClass : configuration.getIncludedTypeElements()) { // If -nodeprecated option is set and the containing package is marked // as deprecated, do not generate the class-use page. We will still generate // the class-use page if the class is marked as deprecated but the containing // package is not since it could still be linked from that package-use page. - if (!(configuration.nodeprecated && - configuration.utils.isDeprecated(configuration.utils.containingPackage(aClass)))) + if (!(nodeprecated && + utils.isDeprecated(utils.containingPackage(aClass)))) ClassUseWriter.generate(configuration, mapper, aClass); } for (PackageElement pkg : configuration.packages) { // If -nodeprecated option is set and the package is marked // as deprecated, do not generate the package-use page. - if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg))) + if (!(nodeprecated && utils.isDeprecated(pkg))) PackageUseWriter.generate(configuration, mapper, pkg); } } --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java 2020-01-21 10:50:51.263761784 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java 2020-01-21 10:50:50.935747290 -0800 @@ -228,7 +228,7 @@ linkInfo.linkToSelf = false; Content className = new StringContent(utils.getSimpleName(typeElement)); Content parameterLinks = getTypeParameterLinks(linkInfo); - if (configuration.linksource) { + if (configuration.getOptions().linkSource) { addSrcLink(typeElement, className, pre); pre.add(parameterLinks); } else { @@ -299,7 +299,7 @@ */ @Override public void addClassDescription(Content classInfoTree) { - if(!configuration.nocomment) { + if(!configuration.getOptions().noComment) { // generate documentation for the class. if (!utils.getFullBody(typeElement).isEmpty()) { addInlineComment(typeElement, classInfoTree); @@ -312,7 +312,7 @@ */ @Override public void addClassTagInfo(Content classInfoTree) { - if(!configuration.nocomment) { + if(!configuration.getOptions().noComment) { // Print Information about all the tags here addTagsInfo(typeElement, classInfoTree); } --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java 2020-01-21 10:50:52.463814807 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java 2020-01-21 10:50:52.143800667 -0800 @@ -259,7 +259,7 @@ /** * Get list of all the deprecated classes and members in all the Packages - * specified on the Command Line. + * specified on the command line. * Then instantiate DeprecatedListWriter and generate File. * * @param configuration the current configuration of the doclet. --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java 2020-01-21 10:50:53.439857932 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java 2020-01-21 10:50:53.115843616 -0800 @@ -64,6 +64,7 @@ public final Location location; public final DocPath source; public final HtmlConfiguration configuration; + private final HtmlOptions options; private Navigation navBar; /** @@ -75,6 +76,7 @@ */ public DocFilesHandlerImpl(HtmlConfiguration configuration, Element element) { this.configuration = configuration; + this.options = configuration.getOptions(); this.element = element; switch (element.getKind()) { @@ -160,7 +162,7 @@ } } } else if (srcfile.isDirectory()) { - if (configuration.copydocfilesubdirs + if (options.copyDocfileSubdirs && !configuration.shouldExcludeDocFileDir(srcfile.getName())) { DocPath dirDocPath = dstDocPath.resolve(srcfile.getName()); copyDirectory(srcfile, dirDocPath, first); --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java 2020-01-21 10:50:54.399900351 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java 2020-01-21 10:50:54.075886034 -0800 @@ -201,7 +201,7 @@ Content classLink = writer.getPreQualifiedClassLink( LinkInfoImpl.Kind.MEMBER, typeElement, false); Content label; - if (configuration.summarizeOverriddenMethods) { + if (options.summarizeOverriddenMethods) { label = new StringContent(utils.isClass(typeElement) ? resources.getText("doclet.Fields_Declared_In_Class") : resources.getText("doclet.Fields_Declared_In_Interface")); --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java 2020-01-21 10:50:55.379943653 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java 2020-01-21 10:50:55.055929336 -0800 @@ -132,7 +132,7 @@ ul.setStyle(HtmlStyle.blockList); // Overview - if (configuration.createoverview) { + if (options.createOverview) { Content overviewHeading = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.overviewLabel); htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, overviewHeading); @@ -246,7 +246,7 @@ ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); // Class Use - if (configuration.classuse) { + if (options.classUse) { Content useHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.getContent("doclet.help.use.head")); htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, useHead); @@ -257,7 +257,7 @@ } // Tree - if (configuration.createtree) { + if (options.createTree) { Content treeHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.getContent("doclet.help.tree.head")); htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, treeHead); @@ -275,7 +275,7 @@ } // Deprecated - if (!(configuration.nodeprecatedlist || configuration.nodeprecated)) { + if (!(options.noDeprecatedList || options.noDeprecated)) { Content dHead = HtmlTree.HEADING(Headings.CONTENT_HEADING, contents.deprecatedAPI); htmlTree = HtmlTree.SECTION(HtmlStyle.helpSection, dHead); @@ -288,9 +288,9 @@ } // Index - if (configuration.createindex) { + if (options.createIndex) { Content indexlink; - if (configuration.splitindex) { + if (options.splitIndex) { indexlink = links.createLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)), resources.getText("doclet.Index")); } else { --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java 2020-01-21 10:50:56.019971931 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java 2020-01-21 10:50:55.767960796 -0800 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.net.*; import java.util.*; import java.util.stream.Collectors; @@ -37,7 +36,6 @@ import javax.tools.StandardJavaFileManager; import com.sun.source.util.DocTreePath; -import com.sun.tools.doclint.DocLint; import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.DocletEnvironment; @@ -53,9 +51,9 @@ import static javax.tools.Diagnostic.Kind.*; /** - * Configure the output based on the command line options. + * Configure the output based on the command-line options. *

- * Also determine the length of the command line option. For example, + * Also determine the length of the command-line option. For example, * for a option "-header" there will be a string argument associated, then the * the length of option "-header" is two. But for option "-nohelp" no argument * is needed so it's length is 1. @@ -77,125 +75,6 @@ */ public static final String HTML_DEFAULT_CHARSET = "utf-8"; - /** - * Argument for command line option "-header". - */ - public String header = ""; - - /** - * Argument for command line option "-packagesheader". - */ - public String packagesheader = ""; - - /** - * Argument for command line option "-footer". - */ - public String footer = ""; - - /** - * Argument for command line option "-doctitle". - */ - public String doctitle = ""; - - /** - * Argument for command line option "-windowtitle". - */ - public String windowtitle = ""; - - /** - * Argument for command line option "-top". - */ - public String top = ""; - - /** - * Argument for command line option "-bottom". - */ - public String bottom = ""; - - /** - * Argument for command line option "-helpfile". - */ - public String helpfile = ""; - - /** - * Argument for command line option "-stylesheetfile". - */ - public String stylesheetfile = ""; - - /** - * Argument for command line option "--add-stylesheet". - */ - public List additionalStylesheets = new ArrayList<>(); - - /** - * Argument for command line option "-Xdocrootparent". - */ - public String docrootparent = ""; - - /** - * True if command line option "-nohelp" is used. Default value is false. - */ - public boolean nohelp = false; - - /** - * True if command line option "-splitindex" is used. Default value is - * false. - */ - public boolean splitindex = false; - - /** - * False if command line option "-noindex" is used. Default value is true. - */ - public boolean createindex = true; - - /** - * True if command line option "-use" is used. Default value is false. - */ - public boolean classuse = false; - - /** - * False if command line option "-notree" is used. Default value is true. - */ - public boolean createtree = true; - - /** - * The META charset tag used for cross-platform viewing. - */ - public String charset = null; - - /** - * True if command line option "-nodeprecated" is used. Default value is - * false. - */ - public boolean nodeprecatedlist = false; - - /** - * True if command line option "-nonavbar" is used. Default value is false. - */ - public boolean nonavbar = false; - - /** - * True if command line option "-nooverview" is used. Default value is - * false - */ - private boolean nooverview = false; - - /** - * The overview path specified with "-overview" flag. - */ - public String overviewpath = null; - - /** - * This is true if option "-overview" is used or option "-overview" is not - * used and number of packages is more than one. - */ - public boolean createoverview = false; - - /** - * Collected set of doclint options - */ - public Map doclintOpts = new LinkedHashMap<>(); - public final Resources resources; /** @@ -231,6 +110,8 @@ public Map> localStylesheetMap = new HashMap<>(); + private final HtmlOptions options; + /** * Creates an object to hold the configuration for a doclet. * @@ -244,6 +125,7 @@ messages = new Messages(this); contents = new Contents(this); + options = new HtmlOptions(this); String v; try { @@ -283,54 +165,14 @@ return messages; } - protected boolean validateOptions() { - // check shared options - if (!generalValidOptions()) { - return false; - } - - // check if helpfile exists - if (!helpfile.isEmpty()) { - DocFile help = DocFile.createFileForInput(this, helpfile); - if (!help.exists()) { - reporter.print(ERROR, resources.getText("doclet.File_not_found", helpfile)); - return false; - } - } - // check if stylesheetfile exists - if (!stylesheetfile.isEmpty()) { - DocFile stylesheet = DocFile.createFileForInput(this, stylesheetfile); - if (!stylesheet.exists()) { - reporter.print(ERROR, resources.getText("doclet.File_not_found", stylesheetfile)); - return false; - } - } - // check if additional stylesheets exists - for (String ssheet : additionalStylesheets) { - DocFile ssfile = DocFile.createFileForInput(this, ssheet); - if (!ssfile.exists()) { - reporter.print(ERROR, resources.getText("doclet.File_not_found", ssheet)); - return false; - } - } - - // In a more object-oriented world, this would be done by methods on the Option objects. - // Note that -windowtitle silently removes any and all HTML elements, and so does not need - // to be handled here. - utils.checkJavaScriptInOption("-header", header); - utils.checkJavaScriptInOption("-footer", footer); - utils.checkJavaScriptInOption("-top", top); - utils.checkJavaScriptInOption("-bottom", bottom); - utils.checkJavaScriptInOption("-doctitle", doctitle); - utils.checkJavaScriptInOption("-packagesheader", packagesheader); - - return true; + @Override + public HtmlOptions getOptions() { + return options; } - @Override public boolean finishOptionSettings() { - if (!validateOptions()) { + if (!options.validateOptions()) { return false; } if (!getSpecifiedTypeElements().isEmpty()) { @@ -346,7 +188,7 @@ docPaths = new DocPaths(utils); setCreateOverview(); setTopFile(docEnv); - workArounds.initDocLint(doclintOpts.values(), tagletManager.getAllTagletNames()); + workArounds.initDocLint(options.doclintOpts.values(), tagletManager.getAllTagletNames()); return true; } @@ -364,7 +206,7 @@ if (!checkForDeprecation(docEnv)) { return; } - if (createoverview) { + if (options.createOverview) { topFile = DocPaths.INDEX; } else { if (showModules) { @@ -382,7 +224,7 @@ } protected TypeElement getValidClass(List classes) { - if (!nodeprecated) { + if (!options.noDeprecated) { return classes.get(0); } for (TypeElement te : classes) { @@ -404,14 +246,14 @@ /** * Generate "overview.html" page if option "-overview" is used or number of - * packages is more than one. Sets {@link #createoverview} field to true. + * packages is more than one. Sets {@link HtmlOptions#createOverview} field to true. */ protected void setCreateOverview() { - if (!nooverview) { - if (overviewpath != null + if (!options.noOverview) { + if (options.overviewPath != null || modules.size() > 1 || (modules.isEmpty() && packages.size() > 1)) { - createoverview = true; + options.createOverview = true; } } } @@ -441,6 +283,7 @@ */ @Override public JavaFileObject getOverviewPath() { + String overviewpath = options.overviewPath; if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) { StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager(); return fm.getJavaFileObjects(overviewpath).iterator().next(); @@ -449,6 +292,7 @@ } public DocPath getMainStylesheet() { + String stylesheetfile = options.stylesheetFile; if(!stylesheetfile.isEmpty()){ DocFile docFile = DocFile.createFileForInput(this, stylesheetfile); return DocPath.create(docFile.getName()); @@ -457,7 +301,7 @@ } public List getAdditionalStylesheets() { - return additionalStylesheets.stream() + return options.additionalStylesheets.stream() .map(ssf -> DocFile.createFileForInput(this, ssf)).map(file -> DocPath.create(file.getName())) .collect(Collectors.toList()); } @@ -497,264 +341,17 @@ } @Override - public Set getSupportedOptions() { - Resources resources = getResources(); - Doclet.Option[] options = { - new Option(resources, "--add-stylesheet", 1) { - @Override - public boolean process(String opt, List args) { - additionalStylesheets.add(args.get(0)); - return true; - } - }, - new Option(resources, "-bottom", 1) { - @Override - public boolean process(String opt, List args) { - bottom = args.get(0); - return true; - } - }, - new Option(resources, "-charset", 1) { - @Override - public boolean process(String opt, List args) { - charset = args.get(0); - return true; - } - }, - new Option(resources, "-doctitle", 1) { - @Override - public boolean process(String opt, List args) { - doctitle = args.get(0); - return true; - } - }, - new Option(resources, "-footer", 1) { - @Override - public boolean process(String opt, List args) { - footer = args.get(0); - return true; - } - }, - new Option(resources, "-header", 1) { - @Override - public boolean process(String opt, List args) { - header = args.get(0); - return true; - } - }, - new Option(resources, "-helpfile", 1) { - @Override - public boolean process(String opt, List args) { - if (nohelp == true) { - reporter.print(ERROR, resources.getText("doclet.Option_conflict", - "-helpfile", "-nohelp")); - return false; - } - if (!helpfile.isEmpty()) { - reporter.print(ERROR, resources.getText("doclet.Option_reuse", - "-helpfile")); - return false; - } - helpfile = args.get(0); - return true; - } - }, - new Option(resources, "-html5") { - @Override - public boolean process(String opt, List args) { - return true; - } - }, - new Option(resources, "-nohelp") { - @Override - public boolean process(String opt, List args) { - nohelp = true; - if (!helpfile.isEmpty()) { - reporter.print(ERROR, resources.getText("doclet.Option_conflict", - "-nohelp", "-helpfile")); - return false; - } - return true; - } - }, - new Option(resources, "-nodeprecatedlist") { - @Override - public boolean process(String opt, List args) { - nodeprecatedlist = true; - return true; - } - }, - new Option(resources, "-noindex") { - @Override - public boolean process(String opt, List args) { - createindex = false; - if (splitindex == true) { - reporter.print(ERROR, resources.getText("doclet.Option_conflict", - "-noindex", "-splitindex")); - return false; - } - return true; - } - }, - new Option(resources, "-nonavbar") { - @Override - public boolean process(String opt, List args) { - nonavbar = true; - return true; - } - }, - new Hidden(resources, "-nooverview") { - @Override - public boolean process(String opt, List args) { - nooverview = true; - if (overviewpath != null) { - reporter.print(ERROR, resources.getText("doclet.Option_conflict", - "-nooverview", "-overview")); - return false; - } - return true; - } - }, - new Option(resources, "-notree") { - @Override - public boolean process(String opt, List args) { - createtree = false; - return true; - } - }, - new Option(resources, "-overview", 1) { - @Override - public boolean process(String opt, List args) { - overviewpath = args.get(0); - if (nooverview == true) { - reporter.print(ERROR, resources.getText("doclet.Option_conflict", - "-overview", "-nooverview")); - return false; - } - return true; - } - }, - new Hidden(resources, "-packagesheader", 1) { - @Override - public boolean process(String opt, List args) { - packagesheader = args.get(0); - return true; - } - }, - new Option(resources, "-splitindex") { - @Override - public boolean process(String opt, List args) { - splitindex = true; - if (createindex == false) { - reporter.print(ERROR, resources.getText("doclet.Option_conflict", - "-splitindex", "-noindex")); - return false; - } - return true; - } - }, - new Option(resources, "--main-stylesheet -stylesheetfile", 1) { - @Override - public boolean process(String opt, List args) { - stylesheetfile = args.get(0); - return true; - } - }, - new Option(resources, "-top", 1) { - @Override - public boolean process(String opt, List args) { - top = args.get(0); - return true; - } - }, - new Option(resources, "-use") { - @Override - public boolean process(String opt, List args) { - classuse = true; - return true; - } - }, - new Option(resources, "-windowtitle", 1) { - @Override - public boolean process(String opt, List args) { - windowtitle = args.get(0).replaceAll("\\<.*?>", ""); - return true; - } - }, - new XOption(resources, "-Xdoclint") { - @Override - public boolean process(String opt, List args) { - doclintOpts.put(this, DocLint.XMSGS_OPTION); - return true; - } - }, - new XOption(resources, "-Xdocrootparent", 1) { - @Override - public boolean process(String opt, List args) { - docrootparent = args.get(0); - try { - URL ignored = new URL(docrootparent); - } catch (MalformedURLException e) { - reporter.print(ERROR, resources.getText("doclet.MalformedURL", docrootparent)); - return false; - } - return true; - } - }, - new XOption(resources, "doclet.usage.xdoclint-extended", "-Xdoclint:", 0) { - @Override - public boolean process(String opt, List args) { - String dopt = opt.replace("-Xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX); - doclintOpts.put(this, dopt); - if (dopt.contains("/")) { - reporter.print(ERROR, resources.getText("doclet.Option_doclint_no_qualifiers")); - return false; - } - if (!DocLint.isValidOption(dopt)) { - reporter.print(ERROR, resources.getText("doclet.Option_doclint_invalid_arg")); - return false; - } - return true; - } - }, - new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) { - @Override - public boolean process(String opt, List args) { - String dopt = opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE); - doclintOpts.put(this, dopt); - if (!DocLint.isValidOption(dopt)) { - reporter.print(ERROR, resources.getText("doclet.Option_doclint_package_invalid_arg")); - return false; - } - return true; - } - }, - new XOption(resources, "--no-frames") { - @Override - public boolean process(String opt, List args) { - reporter.print(WARNING, resources.getText("doclet.NoFrames_specified")); - return true; - } - } - }; - Set oset = new TreeSet<>(); - oset.addAll(Arrays.asList(options)); - oset.addAll(super.getSupportedOptions()); - return oset; - } - - @Override protected boolean finishOptionSettings0() throws DocletException { - if (docencoding == null) { - if (charset == null) { - docencoding = charset = (encoding == null) ? HTML_DEFAULT_CHARSET : encoding; + if (options.docEncoding == null) { + if (options.charset == null) { + options.docEncoding = options.charset = (options.encoding == null) ? HTML_DEFAULT_CHARSET : options.encoding; } else { - docencoding = charset; + options.docEncoding = options.charset; } } else { - if (charset == null) { - charset = docencoding; - } else if (!charset.equals(docencoding)) { + if (options.charset == null) { + options.charset = options.docEncoding; + } else if (!options.charset.equals(options.docEncoding)) { reporter.print(ERROR, resources.getText("doclet.Option_conflict", "-charset", "-docencoding")); return false; } --- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java 2020-01-21 10:50:56.820007280 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java 2020-01-21 10:50:56.495992964 -0800 @@ -108,7 +108,8 @@ protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree) throws DocletException { super.generateOtherFiles(docEnv, classtree); - if (configuration.linksource) { + HtmlOptions options = configuration.getOptions(); + if (options.linkSource) { SourceToHTMLConverter.convertRoot(configuration, docEnv, DocPaths.SOURCE_OUTPUT); } @@ -119,27 +120,27 @@ messages.error("doclet.No_Non_Deprecated_Classes_To_Document"); return; } - boolean nodeprecated = configuration.nodeprecated; - performCopy(configuration.helpfile); - performCopy(configuration.stylesheetfile); - for (String stylesheet : configuration.additionalStylesheets) { + boolean nodeprecated = options.noDeprecated; + performCopy(options.helpFile); + performCopy(options.stylesheetFile); + for (String stylesheet : options.additionalStylesheets) { performCopy(stylesheet); } // do early to reduce memory footprint - if (configuration.classuse) { + if (options.classUse) { ClassUseWriter.generate(configuration, classtree); } IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated); - if (configuration.createtree) { + if (options.createTree) { TreeWriter.generate(configuration, classtree); } - if (!(configuration.nodeprecatedlist || nodeprecated)) { + if (!(options.noDeprecatedList || nodeprecated)) { DeprecatedListWriter.generate(configuration); } - if (configuration.createoverview) { + if (options.createOverview) { if (configuration.showModules) { ModuleIndexWriter.generate(configuration); } else { @@ -147,9 +148,9 @@ } } - if (configuration.createindex) { + if (options.createIndex) { configuration.buildSearchTagIndex(); - if (configuration.splitindex) { + if (options.splitIndex) { SplitIndexWriter.generate(configuration, indexbuilder); } else { SingleIndexWriter.generate(configuration, indexbuilder); @@ -162,25 +163,25 @@ SystemPropertiesWriter.generate(configuration); } - if (configuration.createoverview) { + if (options.createOverview) { IndexRedirectWriter.generate(configuration, DocPaths.OVERVIEW_SUMMARY, DocPaths.INDEX); } else { IndexRedirectWriter.generate(configuration); } - if (configuration.helpfile.isEmpty() && !configuration.nohelp) { + if (options.helpFile.isEmpty() && !options.noHelp) { HelpWriter.generate(configuration); } // If a stylesheet file is not specified, copy the default stylesheet // and replace newline with platform-specific newline. DocFile f; - if (configuration.stylesheetfile.length() == 0) { + if (options.stylesheetFile.length() == 0) { f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET); f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), true, true); } f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT); f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true); - if (configuration.createindex) { + if (options.createIndex) { f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS); f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS), true, true); @@ -272,26 +273,27 @@ */ @Override // defined by AbstractDoclet protected void generatePackageFiles(ClassTree classtree) throws DocletException { + HtmlOptions options = configuration.getOptions(); Set packages = configuration.packages; List pList = new ArrayList<>(packages); for (PackageElement pkg : pList) { // if -nodeprecated option is set and the package is marked as // deprecated, do not generate the package-summary.html, package-frame.html // and package-tree.html pages for that package. - if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { + if (!(options.noDeprecated && utils.isDeprecated(pkg))) { AbstractBuilder packageSummaryBuilder = configuration.getBuilderFactory().getPackageSummaryBuilder(pkg); packageSummaryBuilder.build(); - if (configuration.createtree) { - PackageTreeWriter.generate(configuration, pkg, configuration.nodeprecated); + if (options.createTree) { + PackageTreeWriter.generate(configuration, pkg, options.noDeprecated); } } } } @Override // defined by Doclet - public Set