--- old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java 2020-01-24 13:16:25.333126106 -0800 +++ new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java 2020-01-24 13:16:25.001111061 -0800 @@ -164,7 +164,7 @@ private final JavaFileManager fm; private final List locations; private final Modules modules; - private final Map opts; + private final ToolOptions options; private final Messager messager; private final JavaCompiler compiler; @@ -201,15 +201,15 @@ * Creates the table to manage included and excluded elements. * * @param context the context to locate commonly used objects - * @param location the location used to locate source files + * @param options the tool options */ - ElementsTable(Context context, Map opts) { + ElementsTable(Context context, ToolOptions options) { this.toolEnv = ToolEnvironment.instance(context); this.syms = Symtab.instance(context); this.names = Names.instance(context); this.fm = toolEnv.fileManager; this.modules = Modules.instance(context); - this.opts = opts; + this.options = options; this.messager = Messager.instance0(context); this.compiler = JavaCompiler.instance(context); Source source = Source.instance(context); @@ -229,9 +229,9 @@ getEntry("").excluded = false; - accessFilter = new ModifierFilter(opts); - xclasses = (boolean)opts.getOrDefault(ToolOption.XCLASSES, false); - expandRequires = (AccessKind)opts.get(ToolOption.EXPAND_REQUIRES); + accessFilter = new ModifierFilter(options); + xclasses = options.xclasses(); + expandRequires = options.expandRequires(); } /** @@ -318,9 +318,7 @@ * * @param e the element in question * - * @see getIncludedModuleElements - * @see getIncludedPackageElements - * @see getIncludedTypeElements + * @see #getIncludedElements() * * @return true if included */ @@ -407,21 +405,19 @@ return null; } - @SuppressWarnings("unchecked") ElementsTable scanSpecifiedItems() throws ToolException { // scan modules specified on the command line - List moduleNames = (List) opts.computeIfAbsent(ToolOption.MODULE, - s -> Collections.EMPTY_LIST); + List modules = options.modules(); List mlist = new ArrayList<>(); - for (String m : moduleNames) { + for (String m : modules) { List moduleLocations = getModuleLocation(locations, m); if (moduleLocations.isEmpty()) { String text = messager.getText("main.module_not_found", m); throw new ToolException(CMDERR, text); } if (moduleLocations.contains(StandardLocation.SOURCE_PATH)) { - sanityCheckSourcePathModules(moduleNames); + sanityCheckSourcePathModules(modules); } mlist.add(m); ModuleSymbol msym = syms.enterModule(names.fromString(m)); @@ -436,8 +432,7 @@ }); // scan for modules with qualified subpackages - ((List)opts.computeIfAbsent(ToolOption.SUBPACKAGES, v -> Collections.EMPTY_LIST)) - .stream() + options.subpackages().stream() .map(ModulePackage::new) .forEachOrdered((mpkg) -> { subPackages.add(mpkg); @@ -448,8 +443,8 @@ // all the modules specified on the command line have been scraped // init the module systems - modules.addExtraAddModules(mlist.toArray(new String[mlist.size()])); - modules.initModules(this.classTreeList); + this.modules.addExtraAddModules(mlist.toArray(new String[mlist.size()])); + this.modules.initModules(this.classTreeList); return this; } @@ -504,10 +499,8 @@ return result; } - @SuppressWarnings("unchecked") private void computeSubpackages() throws ToolException { - ((List) opts.computeIfAbsent(ToolOption.EXCLUDE, v -> Collections.EMPTY_LIST)) - .stream() + options.excludes().stream() .map(ModulePackage::new) .forEachOrdered((mpkg) -> excludePackages.add(mpkg)); @@ -830,7 +823,7 @@ /** * Returns the set of source files for a package. * - * @param packageName the specified package + * @param modpkg the specified package * @return the set of file objects for the specified package * @throws ToolException if an error occurs while accessing the files */ @@ -1214,24 +1207,24 @@ /** * Constructor - Specify a filter. * - * @param accessSet an Access filter. + * @param options the tool options */ - ModifierFilter(Map opts) { + ModifierFilter(ToolOptions options) { AccessKind accessValue = null; for (ElementKind kind : ALLOWED_KINDS) { switch (kind) { case METHOD: - accessValue = (AccessKind)opts.get(ToolOption.SHOW_MEMBERS); + accessValue = options.showMembersAccess(); break; case CLASS: - accessValue = (AccessKind)opts.get(ToolOption.SHOW_TYPES); + accessValue = options.showTypesAccess(); break; case PACKAGE: - accessValue = (AccessKind)opts.get(ToolOption.SHOW_PACKAGES); + accessValue = options.showPackagesAccess(); break; case MODULE: - accessValue = (AccessKind)opts.get(ToolOption.SHOW_MODULE_CONTENTS); + accessValue = options.showModuleContents(); break; default: throw new AssertionError("unknown element: " + kind);