diff --git a/jdk/make/src/classes/build/tools/docs/GenDocsBundlePage.java b/jdk/make/src/classes/build/tools/docs/GenDocsBundlePage.java index 3b73067568f..ef1eb433279 100644 --- a/jdk/make/src/classes/build/tools/docs/GenDocsBundlePage.java +++ b/jdk/make/src/classes/build/tools/docs/GenDocsBundlePage.java @@ -31,18 +31,23 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; +import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleFinder; +import java.lang.module.ModuleReference; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Comparator; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.stream.Collectors; +import java.util.function.Predicate; import java.util.stream.Stream; +import static java.util.stream.Collectors.*; /** * Build tool to generate the docs bundle index page. @@ -104,59 +109,33 @@ public class GenDocsBundlePage { } private static final String HEADER_TITLE = "@HEADER_TITLE@"; + + final Path outputfile; final String title; - final Map moduleGroups; - + final Map> moduleGroups = new HashMap<>(); GenDocsBundlePage(String title, Path outputfile) throws IOException { this.outputfile = outputfile; this.title = title; - this.moduleGroups = moduleGroups(); - } - static Map moduleGroups() throws IOException { + // read module groups ModuleFinder finder = ModuleFinder.ofSystem(); - Map groups = new HashMap<>(); try (InputStream in = GenDocsBundlePage.class.getResourceAsStream(MODULE_GROUPS_PROPS)) { Properties props = new Properties(); props.load(in); for (String key: props.stringPropertyNames()) { - Set mods = Stream.of(props.getProperty(key).split("\\s+")) - .filter(mn -> finder.find(mn).isPresent()) - .map(String::trim) - .collect(Collectors.toSet()); + Set mods = + Stream.of(props.getProperty(key).split("\\s+")) + .map(String::trim) + .flatMap(mn -> finder.find(mn).stream()) + .map(ModuleReference::descriptor) + .collect(toSet()); - // divide into 3 columns: Java SE, JDK, JavaFX - StringBuilder sb = new StringBuilder(); - sb.append(mods.stream() - .filter(mn -> mn.startsWith("java.")) - .sorted() - .map(GenDocsBundlePage::toHRef) - .collect(Collectors.joining("\n"))); - sb.append("\n") - .append(mods.stream() - .filter(mn -> mn.startsWith("jdk.")) - .sorted() - .map(GenDocsBundlePage::toHRef) - .collect(Collectors.joining("\n"))); - sb.append("\n"); - if (mods.stream().anyMatch(mn -> mn.startsWith("javafx."))) { - sb.append(mods.stream() - .filter(mn -> mn.startsWith("javafx.")) - .sorted() - .map(GenDocsBundlePage::toHRef) - .collect(Collectors.joining("\n"))); - } String name = "@" + key.toUpperCase(Locale.ENGLISH) + "@"; - groups.put(name, sb.toString()); - } + moduleGroups.put(name, mods); + }; } - return groups; - } - - static String toHRef(String mn) { - return String.format("%s
", mn, mn); } void run(BufferedReader reader) throws IOException { @@ -174,13 +153,95 @@ public class GenDocsBundlePage { if (line.contains(HEADER_TITLE)) { line = line.replace(HEADER_TITLE, title); } - if (line.contains("@")) { - for (Map.Entry e: moduleGroups.entrySet()) { - if (line.contains(e.getKey())) { - line = line.replace(e.getKey(), e.getValue()); - } + int i = line.indexOf('@'); + int j = line.indexOf('@', i+1); + if (i >= 0 && i < j) { + String name = line.substring(i, j+1); + if (moduleGroups.containsKey(name)) { + line = line.replace(name, formatModuleGroup(name)); } } return line; } + + String toHRef(ModuleDescriptor md) { + String mn = md.name(); + String formattedName; + if (hasExportedAPIs(md)) { + // has exported APIs + formattedName = mn; + } else if (!md.provides().isEmpty()) { + // a provider + formattedName = "" + mn + ""; + } else { + // a tool + formattedName = "" + mn + ""; + } + return String.format("%s", + mn, formattedName); + } + + String formatModuleGroup(String groupName) { + StringBuilder sb = new StringBuilder(); + // organize in Java SE, JDK, JavaFX, JCP groups + Set modules = moduleGroups.get(groupName); + Arrays.stream(ModuleGroup.values()) + .forEach(g -> { + Set mods = modules.stream() + .filter(md -> g.predicate.test(md.name())) + .collect(toSet()); + if (!mods.isEmpty()) { + sb.append("
\n"); + // modules with exported API + mods.stream() + .filter(this::hasExportedAPIs) + .sorted(Comparator.comparing(ModuleDescriptor::name)) + .map(this::toHRef) + .forEach(m -> sb.append(m).append("\n")); + + // tools and providers + mods.stream() + .filter(md -> !hasExportedAPIs(md)) + .sorted(Comparator.comparing(ModuleDescriptor::name)) + .map(this::toHRef) + .forEach(m -> sb.append(m).append("\n")); + sb.append("
"); + } + }); + return sb.toString(); + } + + private boolean hasExportedAPIs(ModuleDescriptor md) { + if (md.exports().stream().anyMatch(e -> !e.isQualified())) { + return true; + } + // this should check if any indirect exports + // checking requires transitive would be sufficient for JDK modules + if (md.requires().stream() + .map(ModuleDescriptor.Requires::modifiers) + .anyMatch(mods -> mods.contains(ModuleDescriptor.Requires.Modifier.TRANSITIVE))) { + return true; + } + return false; + } + + private static final Set NON_JAVA_SE_MODULES = + Set.of("java.jnlp", "java.smartcardio"); + + /** + * CSS class names are defined in docs-bundle-page.html + */ + enum ModuleGroup { + JAVA_SE("javase", mn -> mn.startsWith("java.") && !NON_JAVA_SE_MODULES.contains(mn)), + JDK("jdk", mn -> mn.startsWith("jdk.")), + JAVAFX("javafx", mn -> mn.startsWith("javafx.")), + NON_JAVA_SE("jcp", NON_JAVA_SE_MODULES::contains); + + final String cssClass; + final Predicate predicate; + ModuleGroup(String cssClass, Predicate predicate) { + this.cssClass = cssClass; + this.predicate = predicate; + } + } } diff --git a/jdk/make/src/classes/build/tools/docs/docs-bundle-page.html b/jdk/make/src/classes/build/tools/docs/docs-bundle-page.html index e309840951d..9a4f5cf0fc4 100644 --- a/jdk/make/src/classes/build/tools/docs/docs-bundle-page.html +++ b/jdk/make/src/classes/build/tools/docs/docs-bundle-page.html @@ -26,91 +26,146 @@ questions. - - - @HEADER_TITLE@ + + + + -

@HEADER_TITLE@

+ - + - - - + - + - - - - - - - - - + - + - - + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + +
ModulesJDK Modules
GroupJava SEJDKJavaFXModules
Foundation@CORE_MODULES@@JAVA_BASE@
Security@SECURITY_MODULES@
Instrumentation and
Management
@INSTRUMENT_MGMT_MODULES@
IntegrationIntegration @INTEGRATION_MODULES@
User Interface@UI_TOOLKITS_MODULES@@UI_MODULES@
Compiler and Scripting@COMPILER_SCRIPTING_MODULES@Compilation@COMPILER_MODULES@
Debugging@DEBUG_MODULES@Scripting@SCRIPTING_MODULES@
Tools and Tool APIs@TOOL_MODULES@Security@SECURITY_MODULES@
Incubating FeaturesManagement@MANAGEMENT_MODULES@
Instrumentation@INSTRUMENT_MODULES@
Serviceability@SVC_MODULES@
Packaging@PACKAGING_MODULES@
Incubator @INCUBATOR_MODULES@
Non-Java SE@OTHER_MODULES@
Java EE @JAVA_EE_MODULES@
Outside Java SEJDKJavaFX
Others@OTHER_MODULES@Aggregator@AGGREGATOR_MODULES@
+

Key: +

    +
  •    Java SE +
  •    JDK +
  •    JavaFX +
  •    Non-Java SE +
  • italic No Exported API (e.g. a tool or provider)
  • +
+

-


-Copyright© 1993, 2017, Oracle and/or its affiliates. All rights reserved.

+
+Copyright © 1993, 2017, Oracle and/or its affiliates. All rights reserved.

+ + + diff --git a/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties b/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties index 0e7d0c8aed1..98a34b91e2e 100644 --- a/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties +++ b/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties @@ -1,13 +1,8 @@ # Module Grouping for the docs bundle page # -core_modules=\ -java.base \ -jdk.charsets \ -jdk.localedata \ -jdk.net \ -jdk.sctp \ -jdk.zipfs +java_base=\ +java.base java_ee_modules=\ java.activation \ @@ -17,6 +12,10 @@ java.xml.bind \ java.xml.ws \ java.xml.ws.annotation +aggregator_modules=\ +java.se \ +java.se.ee + security_modules=\ java.security.jgss \ java.security.sasl \ @@ -26,18 +25,22 @@ jdk.security.jgss \ jdk.crypto.cryptoki \ jdk.crypto.ec \ jdk.crypto.mscapi \ -jdk.crypto.ucrypto +jdk.crypto.ucrypto \ +jdk.policytool -instrument_mgmt_modules=\ -java.instrument \ +instrument_modules=\ +java.instrument + +management_modules=\ java.management \ java.management.rmi \ -jdk.jfr \ jdk.management \ jdk.management.agent \ jdk.management.cmm \ jdk.management.jfr \ jdk.management.resource \ +jdk.snmp \ +jdk.jconsole integration_modules=\ java.logging \ @@ -47,11 +50,18 @@ java.rmi \ java.sql \ java.sql.rowset \ java.xml \ +jdk.charsets \ +jdk.localedata \ +jdk.net \ +jdk.sctp \ +jdk.jsobject \ jdk.httpserver \ jdk.naming.dns \ -jdk.naming.rmi +jdk.naming.rmi \ +jdk.xml.dom \ +jdk.zipfs -ui_toolkits_modules=\ +ui_modules=\ java.datatransfer \ java.desktop \ javafx.base \ @@ -63,39 +73,40 @@ javafx.swing \ javafx.web \ jdk.accessibility -other_modules=\ -java.jnlp \ -java.smartcardio \ -jdk.jsobject \ -jdk.xml.dom - -debug_modules=\ -jdk.jdi \ -jdk.jdwp.agent - -tool_modules=\ +svc_modules=\ +jdk.jfr \ jdk.attach \ -jdk.editpad \ -jdk.jartool \ -jdk.javadoc \ jdk.jcmd \ -jdk.jconsole \ -jdk.jdeps \ -jdk.jlink \ -jdk.jshell \ +jdk.jdi \ +jdk.jdwp.agent \ jdk.jstatd \ +jdk.hotspot.agent + +packaging_modules=\ +jdk.jartool \ +jdk.jlink \ jdk.pack \ -jdk.policytool \ -jdk.packager.services \ +jdk.packager.services + +compiler_modules=\ +java.compiler \ +jdk.compiler \ +jdk.javadoc \ +jdk.jdeps \ +jdk.editpad \ +jdk.jshell \ jdk.rmic -compiler_scripting_modules=\ -java.compiler \ +scripting_modules=\ java.scripting \ -jdk.compiler \ jdk.dynalink \ jdk.scripting.nashorn \ jdk.scripting.nashorn.shell +other_modules=\ +java.jnlp \ +java.smartcardio + incubator_modules=\ jdk.incubator.httpclient +