--- old/make/Javadoc.gmk 2017-03-25 14:45:31.000000000 -0700 +++ new/make/Javadoc.gmk 2017-03-25 14:45:31.000000000 -0700 @@ -27,6 +27,7 @@ include $(SPEC) include MakeBase.gmk include $(JDK_TOPDIR)/make/Tools.gmk +include $(JDK_TOPDIR)/make/ModuleTools.gmk ################################################################################ @@ -174,6 +175,7 @@ -tag param \ -tag return \ -tag throws \ + -taglet build.tools.taglet.ModuleGraph \ -tag since \ -tag version \ -tag serialData \ @@ -188,6 +190,13 @@ DEFAULT_JAVADOC_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \ -serialwarn -encoding ISO-8859-1 -breakiterator --system none +# +# TODO: this should be set by the configure option. +# +ifndef ENABLE_MODULE_GRAPH + ENABLE_MODULE_GRAPH=false +endif + ################################################################################ # Setup make rules for running javadoc. # @@ -321,7 +330,8 @@ $$(eval $$(call ListPathsSafely, $1_PACKAGES, $$($1_PACKAGES_FILE))) endif $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/docs/$1.javadoc, \ - $$($1_JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) -d $$(@D) \ + $$($1_JAVA) -Djava.awt.headless=true -DenableModuleGraph=$(ENABLE_MODULE_GRAPH) \ + $(NEW_JAVADOC) -d $$(@D) \ $$(DEFAULT_JAVADOC_TAGS) $$(DEFAULT_JAVADOC_OPTIONS) \ --module-source-path $$(call PathList, $$(JAVADOC_SOURCE_DIRS)) \ $$($1_OPTIONS) $$($1_PACKAGES_ARG)) @@ -735,18 +745,34 @@ ZIP_TARGETS += $(JAVADOC_ARCHIVE) ################################################################################ +# generate .dot files for module graphs + +JAVADOC_MODULE_GRAPHS_DIR := $(SUPPORT_OUTPUTDIR)/docs/module-graphs +JAVADOC_MODULE_GRAPHS := $(JAVADOC_MODULE_GRAPHS_DIR)/java.se.dot +JAVADOC_MODULE_GRAPHS_ATTRIBUTES := $(JDK_TOPDIR)/make/src/classes/build/tools/jigsaw/javadoc-graphs.properties + +$(JAVADOC_MODULE_GRAPHS): $(BUILD_JIGSAW_TOOLS) $(JAVADOC_MODULE_GRAPHS_ATTRIBUTES) + $(MKDIR) -p $(@D) + $(TOOL_GENGRAPHS) --spec --output $(JAVADOC_MODULE_GRAPHS_DIR) \ + --dot-attributes $(JAVADOC_MODULE_GRAPHS_ATTRIBUTES) + +MODULE_GRAPH_TARGETS += $(JAVADOC_MODULE_GRAPHS) + +################################################################################ # Hook to include the corresponding custom file, if present. $(eval $(call IncludeCustomExtension, , Javadoc.gmk)) ################################################################################ +docs-module-graphs: $(MODULE_GRAPH_TARGETS) + docs-javadoc: $(TARGETS) docs-copy: $(COPY_TARGETS) docs-zip: $(ZIP_TARGETS) -all: docs-javadoc docs-copy docs-zip +all: docs-module-graphs docs-javadoc docs-copy docs-zip -.PHONY: default all docs-javadoc docs-copy docs-zip +.PHONY: default all docs-module-graphs docs-javadoc docs-copy docs-zip --- old/make/Main.gmk 2017-03-25 14:45:31.000000000 -0700 +++ new/make/Main.gmk 2017-03-25 14:45:31.000000000 -0700 @@ -363,6 +363,9 @@ ################################################################################ # Docs targets +docs-module-graphs: + +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-module-graphs) + docs-javadoc: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-javadoc) @@ -375,7 +378,7 @@ update-build-docs: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f UpdateBuildDocs.gmk) -ALL_TARGETS += docs-javadoc docs-copy docs-zip update-build-docs +ALL_TARGETS += docs-module-graphs docs-javadoc docs-copy docs-zip update-build-docs ################################################################################ # Cross compilation support @@ -772,6 +775,8 @@ bootcycle-images: jdk-image + docs-module-graphs: exploded-image buildtools-modules + docs-javadoc: $(GENSRC_TARGETS) rmic # The gensrc step for jdk.jdi creates an html file that is used by docs-copy. @@ -929,7 +934,7 @@ endif # This target builds the documentation image -docs-image: docs-javadoc docs-copy +docs-image: docs-module-graphs docs-javadoc docs-copy # This target builds the test image test-image: prepare-test-image test-image-hotspot-jtreg-native \ --- old/corba/src/java.corba/share/classes/module-info.java 2017-03-25 14:45:32.000000000 -0700 +++ new/corba/src/java.corba/share/classes/module-info.java 2017-03-25 14:45:32.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Java binding of the OMG CORBA APIs, and the RMI-IIOP API. * + * @moduleGraph * @since 9 */ @Deprecated(since="9", forRemoval=true) --- old/jaxp/src/java.xml/share/classes/module-info.java 2017-03-25 14:45:32.000000000 -0700 +++ new/jaxp/src/java.xml/share/classes/module-info.java 2017-03-25 14:45:32.000000000 -0700 @@ -27,6 +27,7 @@ * Defines the Java API for XML Processing (JAXP), the Streaming API for XML (StAX), * the Simple API for XML (SAX), and the W3C Document Object Model (DOM) API. * + * @moduleGraph * @since 9 */ module java.xml { --- old/jaxp/src/jdk.xml.dom/share/classes/module-info.java 2017-03-25 14:45:33.000000000 -0700 +++ new/jaxp/src/jdk.xml.dom/share/classes/module-info.java 2017-03-25 14:45:33.000000000 -0700 @@ -27,6 +27,7 @@ * Defines the subset of the W3C Document Object Model (DOM) API that is not part * of the Java SE API. * + * @moduleGraph * @since 9 */ module jdk.xml.dom { --- old/jaxws/src/java.activation/share/classes/module-info.java 2017-03-25 14:45:33.000000000 -0700 +++ new/jaxws/src/java.activation/share/classes/module-info.java 2017-03-25 14:45:33.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the JavaBeans Activation Framework (JAF) API. * + * @moduleGraph * @since 9 */ @Deprecated(since="9", forRemoval=true) --- old/jaxws/src/java.xml.bind/share/classes/module-info.java 2017-03-25 14:45:34.000000000 -0700 +++ new/jaxws/src/java.xml.bind/share/classes/module-info.java 2017-03-25 14:45:33.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Java Architecture for XML Binding (JAXB) API. * + * @moduleGraph * @since 9 */ @Deprecated(since="9", forRemoval=true) --- old/jaxws/src/java.xml.ws.annotation/share/classes/module-info.java 2017-03-25 14:45:34.000000000 -0700 +++ new/jaxws/src/java.xml.ws.annotation/share/classes/module-info.java 2017-03-25 14:45:34.000000000 -0700 @@ -27,6 +27,7 @@ * Defines a subset of the Common Annotations API to support programs running * on the Java SE Platform. * + * @moduleGraph * @since 9 */ @Deprecated(since="9", forRemoval=true) --- old/jaxws/src/java.xml.ws/share/classes/module-info.java 2017-03-25 14:45:35.000000000 -0700 +++ new/jaxws/src/java.xml.ws/share/classes/module-info.java 2017-03-25 14:45:34.000000000 -0700 @@ -27,6 +27,7 @@ * Defines the Java API for XML-Based Web Services (JAX-WS), and * the Web Services Metadata API. * + * @moduleGraph * @since 9 */ @Deprecated(since="9", forRemoval=true) --- old/jdk/make/GenerateModuleSummary.gmk 2017-03-25 14:45:35.000000000 -0700 +++ new/jdk/make/GenerateModuleSummary.gmk 2017-03-25 14:45:35.000000000 -0700 @@ -31,7 +31,7 @@ include ModuleTools.gmk GENGRAPHS_DIR := $(IMAGES_OUTPUTDIR)/gengraphs -SPEC_DOTFILES_DIR := $(IMAGES_OUTPUTDIR)/spec-dotfiles +SPEC_DOTFILES_DIR := $(GENGRAPHS_DIR)/spec-dotfiles TOOLS_MODULE_SRCDIR := $(JDK_TOPDIR)/make/src/classes/build/tools/jigsaw $(GENGRAPHS_DIR)/jdk.dot: $(BUILD_JIGSAW_TOOLS) --- old/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java 2017-03-25 14:45:36.000000000 -0700 +++ new/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java 2017-03-25 14:45:36.000000000 -0700 @@ -26,7 +26,6 @@ package build.tools.jigsaw; import com.sun.tools.jdeps.ModuleDotGraph; -import com.sun.tools.jdeps.ModuleDotGraph.DotGraphBuilder; import java.io.IOException; import java.lang.module.Configuration; @@ -36,10 +35,15 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; /** * Generate the DOT file for a module graph for each module in the JDK @@ -50,13 +54,19 @@ public static void main(String[] args) throws Exception { Path dir = null; boolean spec = false; + Properties props = null; for (int i=0; i < args.length; i++) { String arg = args[i]; if (arg.equals("--spec")) { spec = true; + } else if (arg.equals("--dot-attributes")) { + if (i++ == args.length) { + throw new IllegalArgumentException("Missing argument: --dot-attributes option"); + } + props = new Properties(); + props.load(Files.newInputStream(Paths.get(args[i]))); } else if (arg.equals("--output")) { - i++; - dir = i < args.length ? Paths.get(args[i]) : null; + dir = ++i < args.length ? Paths.get(args[i]) : null; } else if (arg.startsWith("-")) { throw new IllegalArgumentException("Invalid option: " + arg); } @@ -67,11 +77,14 @@ System.exit(1); } - // setup and configure the dot graph attributes - initDotGraphAttributes(); Files.createDirectories(dir); - - GenGraphs genGraphs = new GenGraphs(dir, spec); + ModuleGraphAttributes attributes; + if (props != null) { + attributes = new ModuleGraphAttributes(props); + } else { + attributes = new ModuleGraphAttributes(); + } + GenGraphs genGraphs = new GenGraphs(dir, spec, attributes); // print dot file for each module Map configurations = new HashMap<>(); @@ -99,49 +112,149 @@ genGraphs.genDotFiles(configurations); } - static void initDotGraphAttributes() { - int h = 1000; - DotGraphBuilder.weight("java.se", "java.sql.rowset", h * 10); - DotGraphBuilder.weight("java.sql.rowset", "java.sql", h * 10); - DotGraphBuilder.weight("java.sql", "java.xml", h * 10); - DotGraphBuilder.weight("java.xml", "java.base", h * 10); - - DotGraphBuilder.sameRankNodes(Set.of("java.logging", "java.scripting", "java.xml")); - DotGraphBuilder.sameRankNodes(Set.of("java.sql")); - DotGraphBuilder.sameRankNodes(Set.of("java.compiler", "java.instrument")); - DotGraphBuilder.sameRankNodes(Set.of("java.desktop", "java.management")); - DotGraphBuilder.sameRankNodes(Set.of("java.corba", "java.xml.ws")); - DotGraphBuilder.sameRankNodes(Set.of("java.xml.bind", "java.xml.ws.annotation")); - DotGraphBuilder.setRankSep(0.7); - DotGraphBuilder.setFontSize(12); - DotGraphBuilder.setArrowSize(1); - DotGraphBuilder.setArrowWidth(2); + /** + * Custom dot file attributes. + */ + static class ModuleGraphAttributes implements ModuleDotGraph.Attributes { + static Map DEFAULT_ATTRIBUTES = Map.of( + "ranksep", "0.6", + "fontsize", "12", + "fontcolor", BLACK, + "fontname", "DejaVuSans bold", + "arrowsize", "1", + "arrowwidth", "2", + "arrowcolor", DARK_GRAY, + // custom + "requiresMandatedColor", LIGHT_GRAY, + "javaSubgraphColor", ORANGE, + "jdkSubgraphColor", BLUE + ); + + final Map weights = new HashMap<>(); + final List> ranks = new ArrayList<>(); + final Map attrs; + ModuleGraphAttributes(Map attrs) { + int h = 1000; + weight("java.se", "java.sql.rowset", h * 10); + weight("java.sql.rowset", "java.sql", h * 10); + weight("java.sql", "java.xml", h * 10); + weight("java.xml", "java.base", h * 10); + + ranks.add(Set.of("java.logging", "java.scripting", "java.xml")); + ranks.add(Set.of("java.sql")); + ranks.add(Set.of("java.compiler", "java.instrument")); + ranks.add(Set.of("java.desktop", "java.management")); + ranks.add(Set.of("java.corba", "java.xml.ws")); + ranks.add(Set.of("java.xml.bind", "java.xml.ws.annotation")); + + this.attrs = attrs; + } + + ModuleGraphAttributes() { + this(DEFAULT_ATTRIBUTES); + } + ModuleGraphAttributes(Properties props) { + this(toAttributes(props)); + } + + @Override + public double rankSep() { + return Double.valueOf(attrs.get("ranksep")); + } + + @Override + public int fontSize() { + return Integer.valueOf(attrs.get("fontsize")); + } + + @Override + public String fontName() { + return attrs.get("fontname"); + } + + @Override + public String fontColor() { + return attrs.get("fontcolor"); + } + + @Override + public int arrowSize() { + return Integer.valueOf(attrs.get("arrowsize")); + } + + @Override + public int arrowWidth() { + return Integer.valueOf(attrs.get("arrowwidth")); + } + + @Override + public String arrowColor() { + return attrs.get("arrowcolor"); + } + + @Override + public List> ranks() { + return ranks; + } + + @Override + public String requiresMandatedColor() { + return attrs.get("requiresMandatedColor"); + } + + @Override + public String javaSubgraphColor() { + return attrs.get("javaSubgraphColor"); + } + + @Override + public String jdkSubgraphColor() { + return attrs.get("jdkSubgraphColor"); + } + + @Override + public int weightOf(String s, String t) { + int w = weights.getOrDefault(s + ":" + t, 1); + if (w != 1) + return w; + if (s.startsWith("java.") && t.startsWith("java.")) + return 10; + return 1; + } + + public void weight(String s, String t, int w) { + weights.put(s + ":" + t, w); + } + + static Map toAttributes(Properties props) { + return DEFAULT_ATTRIBUTES.keySet().stream() + .collect(Collectors.toMap(Function.identity(), + k -> props.getProperty(k, DEFAULT_ATTRIBUTES.get(k)))); + } } private final Path dir; private final boolean spec; - GenGraphs(Path dir, boolean spec) { + private final ModuleGraphAttributes attributes; + GenGraphs(Path dir, boolean spec, ModuleGraphAttributes attributes) { this.dir = dir; this.spec = spec; + this.attributes = attributes; } void genDotFiles(Map configurations) throws IOException { ModuleDotGraph dotGraph = new ModuleDotGraph(configurations, spec); - dotGraph.genDotFiles(dir); + dotGraph.genDotFiles(dir, attributes); } + /** + * Returns true for any name if generating graph for non-spec; + * otherwise, returns true except "jdk" and name with "jdk.internal." prefix + */ boolean accept(String name, ModuleDescriptor descriptor) { - if (!spec) return true; - - if (name.equals("jdk")) - return false; - - if (name.equals("java.se") || name.equals("java.se.ee")) + if (!spec) return true; - // only the module that has exported API - return descriptor.exports().stream() - .filter(e -> !e.isQualified()) - .findAny().isPresent(); + return !name.equals("jdk") && !name.startsWith("jdk.internal."); } -} \ No newline at end of file +} --- old/jdk/src/java.base/share/classes/module-info.java 2017-03-25 14:45:36.000000000 -0700 +++ new/jdk/src/java.base/share/classes/module-info.java 2017-03-25 14:45:36.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the foundational APIs of the Java SE Platform. * + * @moduleGraph * @since 9 */ module java.base { --- old/jdk/src/java.datatransfer/share/classes/module-info.java 2017-03-25 14:45:37.000000000 -0700 +++ new/jdk/src/java.datatransfer/share/classes/module-info.java 2017-03-25 14:45:37.000000000 -0700 @@ -24,8 +24,9 @@ */ /** - * Defines an API for transferring data between and within applications. + * Defines the API for transferring data between and within applications. * + * @moduleGraph * @since 9 */ module java.datatransfer { --- old/jdk/src/java.desktop/share/classes/module-info.java 2017-03-25 14:45:38.000000000 -0700 +++ new/jdk/src/java.desktop/share/classes/module-info.java 2017-03-25 14:45:38.000000000 -0700 @@ -27,6 +27,7 @@ * Defines the AWT and Swing user interface toolkits, plus APIs for * accessibility, audio, imaging, printing, and JavaBeans. * + * @moduleGraph * @since 9 */ module java.desktop { --- old/jdk/src/java.instrument/share/classes/module-info.java 2017-03-25 14:45:39.000000000 -0700 +++ new/jdk/src/java.instrument/share/classes/module-info.java 2017-03-25 14:45:38.000000000 -0700 @@ -27,6 +27,7 @@ * Defines services that allow agents to * instrument programs running on the JVM. * + * @moduleGraph * @since 9 */ module java.instrument { --- old/jdk/src/java.logging/share/classes/module-info.java 2017-03-25 14:45:39.000000000 -0700 +++ new/jdk/src/java.logging/share/classes/module-info.java 2017-03-25 14:45:39.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Java Logging API. * + * @moduleGraph * @since 9 */ module java.logging { --- old/jdk/src/java.management.rmi/share/classes/module-info.java 2017-03-25 14:45:40.000000000 -0700 +++ new/jdk/src/java.management.rmi/share/classes/module-info.java 2017-03-25 14:45:40.000000000 -0700 @@ -46,6 +46,7 @@ * and load the appropriate {@code JMXConnectorServerProvider} service * implementation for the given protocol. * + * @moduleGraph * @since 9 */ module java.management.rmi { --- old/jdk/src/java.management/share/classes/module-info.java 2017-03-25 14:45:40.000000000 -0700 +++ new/jdk/src/java.management/share/classes/module-info.java 2017-03-25 14:45:40.000000000 -0700 @@ -29,6 +29,7 @@ * The JMX API consists of interfaces for monitoring and management of the * JVM and other components in the Java runtime. * + * @moduleGraph * @since 9 */ module java.management { --- old/jdk/src/java.naming/share/classes/module-info.java 2017-03-25 14:45:41.000000000 -0700 +++ new/jdk/src/java.naming/share/classes/module-info.java 2017-03-25 14:45:41.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Java Naming and Directory Interface (JNDI) API. * + * @moduleGraph * @since 9 */ module java.naming { --- old/jdk/src/java.prefs/share/classes/module-info.java 2017-03-25 14:45:42.000000000 -0700 +++ new/jdk/src/java.prefs/share/classes/module-info.java 2017-03-25 14:45:41.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Preferences API. * + * @moduleGraph * @since 9 */ module java.prefs { --- old/jdk/src/java.rmi/share/classes/module-info.java 2017-03-25 14:45:42.000000000 -0700 +++ new/jdk/src/java.rmi/share/classes/module-info.java 2017-03-25 14:45:42.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Remote Method Invocation (RMI) API. * + * @moduleGraph * @since 9 */ module java.rmi { --- old/jdk/src/java.scripting/share/classes/module-info.java 2017-03-25 14:45:43.000000000 -0700 +++ new/jdk/src/java.scripting/share/classes/module-info.java 2017-03-25 14:45:43.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Scripting API. * + * @moduleGraph * @since 9 */ module java.scripting { --- old/jdk/src/java.se.ee/share/classes/module-info.java 2017-03-25 14:45:44.000000000 -0700 +++ new/jdk/src/java.se.ee/share/classes/module-info.java 2017-03-25 14:45:43.000000000 -0700 @@ -29,6 +29,7 @@ * This module requires {@code java.se} and supplements it with modules * that define CORBA and Java EE APIs. These modules are upgradeable. * + * @moduleGraph * @since 9 */ @SuppressWarnings("deprecation") --- old/jdk/src/java.se/share/classes/module-info.java 2017-03-25 14:45:44.000000000 -0700 +++ new/jdk/src/java.se/share/classes/module-info.java 2017-03-25 14:45:44.000000000 -0700 @@ -29,6 +29,7 @@ * The modules defining CORBA and Java EE APIs are not required by * this module, but they are required by {@code java.se.ee}. * + * @moduleGraph * @since 9 */ module java.se { --- old/jdk/src/java.security.jgss/share/classes/module-info.java 2017-03-25 14:45:45.000000000 -0700 +++ new/jdk/src/java.security.jgss/share/classes/module-info.java 2017-03-25 14:45:45.000000000 -0700 @@ -28,6 +28,7 @@ *

* This module also contains GSS-API mechanisms including Kerberos v5 and SPNEGO. * + * @moduleGraph * @since 9 */ module java.security.jgss { --- old/jdk/src/java.security.sasl/share/classes/module-info.java 2017-03-25 14:45:45.000000000 -0700 +++ new/jdk/src/java.security.sasl/share/classes/module-info.java 2017-03-25 14:45:45.000000000 -0700 @@ -30,6 +30,7 @@ * This module also contains SASL mechanisms including DIGEST-MD5, * CRAM-MD5, and NTLM. * + * @moduleGraph * @since 9 */ module java.security.sasl { --- old/jdk/src/java.smartcardio/share/classes/module-info.java 2017-03-25 14:45:46.000000000 -0700 +++ new/jdk/src/java.smartcardio/share/classes/module-info.java 2017-03-25 14:45:46.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Java Smart Card I/O API. * + * @moduleGraph * @since 9 */ module java.smartcardio { --- old/jdk/src/java.sql.rowset/share/classes/module-info.java 2017-03-25 14:45:47.000000000 -0700 +++ new/jdk/src/java.sql.rowset/share/classes/module-info.java 2017-03-25 14:45:46.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the JDBC RowSet API. * + * @moduleGraph * @since 9 */ module java.sql.rowset { --- old/jdk/src/java.sql/share/classes/module-info.java 2017-03-25 14:45:47.000000000 -0700 +++ new/jdk/src/java.sql/share/classes/module-info.java 2017-03-25 14:45:47.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the JDBC API. * + * @moduleGraph * @since 9 */ module java.sql { --- old/jdk/src/java.transaction/share/classes/module-info.java 2017-03-25 14:45:48.000000000 -0700 +++ new/jdk/src/java.transaction/share/classes/module-info.java 2017-03-25 14:45:48.000000000 -0700 @@ -29,6 +29,7 @@ * The subset consists of RMI exception types which are mapped to CORBA system * exceptions by the 'Java Language to IDL Mapping Specification'. * + * @moduleGraph * @since 9 */ @Deprecated(since="9", forRemoval=true) --- old/jdk/src/java.xml.crypto/share/classes/module-info.java 2017-03-25 14:45:49.000000000 -0700 +++ new/jdk/src/java.xml.crypto/share/classes/module-info.java 2017-03-25 14:45:48.000000000 -0700 @@ -24,8 +24,9 @@ */ /** - * Defines an API for XML cryptography. + * Defines the API for XML cryptography. * + * @moduleGraph * @since 9 */ module java.xml.crypto { --- old/jdk/src/jdk.attach/share/classes/module-info.java 2017-03-25 14:45:49.000000000 -0700 +++ new/jdk/src/jdk.attach/share/classes/module-info.java 2017-03-25 14:45:49.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the attach API. * + * @moduleGraph * @since 9 */ module jdk.attach { --- old/jdk/src/jdk.charsets/share/classes/module-info.java 2017-03-25 14:45:50.000000000 -0700 +++ new/jdk/src/jdk.charsets/share/classes/module-info.java 2017-03-25 14:45:50.000000000 -0700 @@ -23,6 +23,13 @@ * questions. */ +/** + * {@link java.nio.charset.Charset Charset} provider for the charsets that + * are not in {@code java.base} mostly double byte and IBM charsets. + * + * @moduleGraph + * @since 9 + */ module jdk.charsets { provides java.nio.charset.spi.CharsetProvider with sun.nio.cs.ext.ExtendedCharsets; --- old/jdk/src/jdk.crypto.cryptoki/share/classes/module-info.java 2017-03-25 14:45:51.000000000 -0700 +++ new/jdk/src/jdk.crypto.cryptoki/share/classes/module-info.java 2017-03-25 14:45:50.000000000 -0700 @@ -26,6 +26,7 @@ /** * The SunPKCS11 security provider. * + * @moduleGraph * @since 9 */ module jdk.crypto.cryptoki { --- old/jdk/src/jdk.crypto.ec/share/classes/module-info.java 2017-03-25 14:45:51.000000000 -0700 +++ new/jdk/src/jdk.crypto.ec/share/classes/module-info.java 2017-03-25 14:45:51.000000000 -0700 @@ -26,6 +26,7 @@ /** * The SunEC security provider. * + * @moduleGraph * @since 9 */ module jdk.crypto.ec { --- old/jdk/src/jdk.crypto.mscapi/windows/classes/module-info.java 2017-03-25 14:45:52.000000000 -0700 +++ new/jdk/src/jdk.crypto.mscapi/windows/classes/module-info.java 2017-03-25 14:45:52.000000000 -0700 @@ -26,6 +26,7 @@ /** * The SunMSCAPI security provider. * + * @moduleGraph * @since 9 */ module jdk.crypto.mscapi { --- old/jdk/src/jdk.crypto.ucrypto/solaris/classes/module-info.java 2017-03-25 14:45:52.000000000 -0700 +++ new/jdk/src/jdk.crypto.ucrypto/solaris/classes/module-info.java 2017-03-25 14:45:52.000000000 -0700 @@ -26,6 +26,7 @@ /** * The OracleUCrypto security provider. * + * @moduleGraph * @since 9 */ module jdk.crypto.ucrypto { --- old/jdk/src/jdk.httpserver/share/classes/module-info.java 2017-03-25 14:45:53.000000000 -0700 +++ new/jdk/src/jdk.httpserver/share/classes/module-info.java 2017-03-25 14:45:53.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Defines the JDK-specific API for HTTP server. + * + * @moduleGraph + * @since 9 + */ module jdk.httpserver { exports com.sun.net.httpserver; --- old/jdk/src/jdk.jartool/share/classes/module-info.java 2017-03-25 14:45:54.000000000 -0700 +++ new/jdk/src/jdk.jartool/share/classes/module-info.java 2017-03-25 14:45:53.000000000 -0700 @@ -23,6 +23,13 @@ * questions. */ +/** + * Defines tools for manipulating Java Archive (JAR) files, + * including the jar and jarsigner tools. + * + * @moduleGraph + * @since 9 + */ module jdk.jartool { exports com.sun.jarsigner; exports jdk.security.jarsigner; --- old/jdk/src/jdk.jcmd/share/classes/module-info.java 2017-03-25 14:45:55.000000000 -0700 +++ new/jdk/src/jdk.jcmd/share/classes/module-info.java 2017-03-25 14:45:54.000000000 -0700 @@ -23,6 +23,13 @@ * questions. */ +/** + * Defines tools for diagnostics and troubleshooting a JVM, + * including the jcmd, jps, jstat and other diagnostics tools. + * + * @moduleGraph + * @since 9 + */ module jdk.jcmd { requires jdk.attach; requires jdk.internal.jvmstat; --- old/jdk/src/jdk.jconsole/share/classes/module-info.java 2017-03-25 14:45:55.000000000 -0700 +++ new/jdk/src/jdk.jconsole/share/classes/module-info.java 2017-03-25 14:45:55.000000000 -0700 @@ -23,6 +23,13 @@ * questions. */ +/** + * Defines the JMX graphical tool, jconsole, for monitoring and managing + * a running application. + * + * @moduleGraph + * @since 9 + */ module jdk.jconsole { requires transitive java.desktop; requires transitive java.management; --- old/jdk/src/jdk.jdi/share/classes/module-info.java 2017-03-25 14:45:56.000000000 -0700 +++ new/jdk/src/jdk.jdi/share/classes/module-info.java 2017-03-25 14:45:56.000000000 -0700 @@ -26,6 +26,7 @@ /** * Defines the Java Debugger Interface. * + * @moduleGraph * @since 9 */ module jdk.jdi { --- old/jdk/src/jdk.jdwp.agent/share/classes/module-info.java 2017-03-25 14:45:57.000000000 -0700 +++ new/jdk/src/jdk.jdwp.agent/share/classes/module-info.java 2017-03-25 14:45:57.000000000 -0700 @@ -26,6 +26,7 @@ /** * Java Debug Wire Protocol. * + * @moduleGraph * @since 9 */ module jdk.jdwp.agent { --- old/jdk/src/jdk.jlink/share/classes/module-info.java 2017-03-25 14:45:57.000000000 -0700 +++ new/jdk/src/jdk.jlink/share/classes/module-info.java 2017-03-25 14:45:57.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Defines the Java linker tool, jlink. + * + * @moduleGraph + * @since 9 + */ module jdk.jlink { requires jdk.internal.opt; requires jdk.jdeps; --- old/jdk/src/jdk.jsobject/share/classes/module-info.java 2017-03-25 14:45:58.000000000 -0700 +++ new/jdk/src/jdk.jsobject/share/classes/module-info.java 2017-03-25 14:45:58.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Defines the API for the JavaScript Object. + * + * @moduleGraph + * @since 9 + */ module jdk.jsobject { requires java.desktop; exports netscape.javascript; --- old/jdk/src/jdk.jstatd/share/classes/module-info.java 2017-03-25 14:45:59.000000000 -0700 +++ new/jdk/src/jdk.jstatd/share/classes/module-info.java 2017-03-25 14:45:58.000000000 -0700 @@ -23,6 +23,13 @@ * questions. */ +/** + * Defines the tool for starting a daemon for the jstat tool to monitor + * JVM statistics remotely. + * + * @moduleGraph + * @since 9 + */ module jdk.jstatd { requires java.rmi; requires jdk.internal.jvmstat; --- old/jdk/src/jdk.localedata/share/classes/module-info.java 2017-03-25 14:45:59.000000000 -0700 +++ new/jdk/src/jdk.localedata/share/classes/module-info.java 2017-03-25 14:45:59.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Locale data provider for locales other than {@linkplain java.util.Locale#US US locale}. + * + * @moduleGraph + * @since 9 + */ module jdk.localedata { provides sun.util.locale.provider.LocaleDataMetaInfo with sun.util.resources.cldr.provider.CLDRLocaleDataMetaInfo, --- old/jdk/src/jdk.management.agent/share/classes/module-info.java 2017-03-25 14:46:00.000000000 -0700 +++ new/jdk/src/jdk.management.agent/share/classes/module-info.java 2017-03-25 14:46:00.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Define the JMX management agent. + * + * @moduleGraph + * @since 9 + */ module jdk.management.agent { requires java.management; requires java.management.rmi; --- old/jdk/src/jdk.management/share/classes/module-info.java 2017-03-25 14:46:01.000000000 -0700 +++ new/jdk/src/jdk.management/share/classes/module-info.java 2017-03-25 14:46:00.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Defines the JDK-specific Management Interfaces for JVM. + * + * @moduleGraph + * @since 9 + */ module jdk.management { requires transitive java.management; --- old/jdk/src/jdk.naming.dns/share/classes/module-info.java 2017-03-25 14:46:01.000000000 -0700 +++ new/jdk/src/jdk.naming.dns/share/classes/module-info.java 2017-03-25 14:46:01.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * DNS Java Naming provider. + * + * @moduleGraph + * @since 9 + */ module jdk.naming.dns { requires java.naming; --- old/jdk/src/jdk.naming.rmi/share/classes/module-info.java 2017-03-25 14:46:02.000000000 -0700 +++ new/jdk/src/jdk.naming.rmi/share/classes/module-info.java 2017-03-25 14:46:02.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * RMI Java Naming provider. + * + * @moduleGraph + * @since 9 + */ module jdk.naming.rmi { requires java.naming; requires java.rmi; --- old/jdk/src/jdk.net/share/classes/module-info.java 2017-03-25 14:46:03.000000000 -0700 +++ new/jdk/src/jdk.net/share/classes/module-info.java 2017-03-25 14:46:02.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Defines the JDK-specific Networking API. + * + * @moduleGraph + * @since 9 + */ module jdk.net { exports jdk.net; } --- old/jdk/src/jdk.sctp/share/classes/module-info.java 2017-03-25 14:46:03.000000000 -0700 +++ new/jdk/src/jdk.sctp/share/classes/module-info.java 2017-03-25 14:46:03.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Defines the JDK-specific API for SCTP. + * + * @moduleGraph + * @since 9 + */ module jdk.sctp { exports com.sun.nio.sctp; } --- old/jdk/src/jdk.security.auth/share/classes/module-info.java 2017-03-25 14:46:04.000000000 -0700 +++ new/jdk/src/jdk.security.auth/share/classes/module-info.java 2017-03-25 14:46:04.000000000 -0700 @@ -27,6 +27,7 @@ * Contains the implementation of the javax.security.auth.* interfaces and * various authentication modules. * + * @moduleGraph * @since 9 */ module jdk.security.auth { --- old/jdk/src/jdk.security.jgss/share/classes/module-info.java 2017-03-25 14:46:04.000000000 -0700 +++ new/jdk/src/jdk.security.jgss/share/classes/module-info.java 2017-03-25 14:46:04.000000000 -0700 @@ -27,6 +27,7 @@ * Defines Java extensions to the GSS-API and an implementation of the SASL * GSSAPI mechanism. * + * @moduleGraph * @since 9 */ module jdk.security.jgss { --- old/jdk/src/jdk.zipfs/share/classes/module-info.java 2017-03-25 14:46:05.000000000 -0700 +++ new/jdk/src/jdk.zipfs/share/classes/module-info.java 2017-03-25 14:46:05.000000000 -0700 @@ -23,6 +23,12 @@ * questions. */ +/** + * Zip file system provider. + * + * @moduleGraph + * @since 9 + */ module jdk.zipfs { provides java.nio.file.spi.FileSystemProvider with jdk.nio.zipfs.ZipFileSystemProvider; } --- old/langtools/src/java.compiler/share/classes/module-info.java 2017-03-25 14:46:06.000000000 -0700 +++ new/langtools/src/java.compiler/share/classes/module-info.java 2017-03-25 14:46:06.000000000 -0700 @@ -30,6 +30,7 @@ * and define interfaces for tools such as compilers which can be invoked * from a program. * + * @moduleGraph * @since 9 */ module java.compiler { --- old/langtools/src/jdk.compiler/share/classes/module-info.java 2017-03-25 14:46:06.000000000 -0700 +++ new/langtools/src/jdk.compiler/share/classes/module-info.java 2017-03-25 14:46:06.000000000 -0700 @@ -27,6 +27,7 @@ * {@link javax.tools.ToolProvider#getSystemJavaCompiler system Java compiler} * and its command line equivalent, javac, as well as javah. * + * @moduleGraph * @since 9 */ module jdk.compiler { --- old/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css 2017-03-25 14:46:07.000000000 -0700 +++ new/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css 2017-03-25 14:46:07.000000000 -0700 @@ -787,3 +787,15 @@ font-style:italic; font-size:12px; } + +.moduleGraph span { + display:none; + position:absolute; +} +.moduleGraph:hover span { + display:block; + margin: -100px 0 0 100px; + z-index: 1; +} + + --- old/langtools/src/jdk.javadoc/share/classes/module-info.java 2017-03-25 14:46:07.000000000 -0700 +++ new/langtools/src/jdk.javadoc/share/classes/module-info.java 2017-03-25 14:46:07.000000000 -0700 @@ -27,6 +27,7 @@ * {@link javax.tools.ToolProvider#getSystemDocumentationTool system documentation tool} * and its command line equivalent, javadoc. * + * @moduleGraph * @since 9 */ module jdk.javadoc { --- old/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleDotGraph.java 2017-03-25 14:46:08.000000000 -0700 +++ new/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleDotGraph.java 2017-03-25 14:46:08.000000000 -0700 @@ -32,6 +32,7 @@ import java.io.PrintWriter; import java.lang.module.Configuration; import java.lang.module.ModuleDescriptor; +import java.lang.module.ModuleDescriptor.*; import java.lang.module.ModuleFinder; import java.lang.module.ModuleReference; import java.lang.module.ResolvedModule; @@ -39,8 +40,8 @@ import java.nio.file.Path; import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Collections; import java.util.Deque; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -76,10 +77,16 @@ * @param dir output directory */ public boolean genDotFiles(Path dir) throws IOException { + return genDotFiles(dir, DotGraphAttributes.DEFAULT); + } + + public boolean genDotFiles(Path dir, Attributes attributes) + throws IOException + { Files.createDirectories(dir); for (String mn : configurations.keySet()) { Path path = dir.resolve(mn + ".dot"); - genDotFile(path, mn, configurations.get(mn)); + genDotFile(path, mn, configurations.get(mn), attributes); } return true; } @@ -87,7 +94,9 @@ /** * Generate dotfile of the given path */ - public void genDotFile(Path path, String name, Configuration configuration) + public void genDotFile(Path path, String name, + Configuration configuration, + Attributes attributes) throws IOException { // transitive reduction @@ -95,12 +104,12 @@ ? requiresTransitiveGraph(configuration, Set.of(name)) : gengraph(configuration); - DotGraphBuilder builder = new DotGraphBuilder(name, graph); - builder.subgraph("se", "java", DotGraphBuilder.ORANGE, + DotGraphBuilder builder = new DotGraphBuilder(name, graph, attributes); + builder.subgraph("se", "java", attributes.javaSubgraphColor(), DotGraphBuilder.JAVA_SE_SUBGRAPH) - .subgraph("jdk", "jdk", DotGraphBuilder.BLUE, + .subgraph("jdk", "jdk", attributes.jdkSubgraphColor(), DotGraphBuilder.JDK_SUBGRAPH) - .descriptors(graph.nodes().stream() + .modules(graph.nodes().stream() .map(mn -> configuration.findModule(mn).get() .reference().descriptor())); // build dot file @@ -118,12 +127,12 @@ private Graph gengraph(Configuration cf) { Graph.Builder builder = new Graph.Builder<>(); cf.modules().stream() - .forEach(resolvedModule -> { - String mn = resolvedModule.reference().descriptor().name(); + .forEach(rm -> { + String mn = rm.name(); builder.addNode(mn); - resolvedModule.reads().stream() - .map(ResolvedModule::name) - .forEach(target -> builder.addEdge(mn, target)); + rm.reads().stream() + .map(ResolvedModule::name) + .forEach(target -> builder.addEdge(mn, target)); }); Graph rpg = requiresTransitiveGraph(cf, builder.nodes); @@ -149,22 +158,103 @@ visited.add(mn); builder.addNode(mn); - ModuleDescriptor descriptor = cf.findModule(mn).get() - .reference().descriptor(); - descriptor.requires().stream() - .filter(d -> d.modifiers().contains(TRANSITIVE) + cf.findModule(mn).get() + .reference().descriptor().requires().stream() + .filter(d -> d.modifiers().contains(TRANSITIVE) || d.name().equals("java.base")) - .map(d -> d.name()) - .forEach(d -> { - deque.add(d); - builder.addEdge(mn, d); - }); + .map(Requires::name) + .forEach(d -> { + deque.add(d); + builder.addEdge(mn, d); + }); } return builder.build().reduce(); } - public static class DotGraphBuilder { + public interface Attributes { + static final String ORANGE = "#e76f00"; + static final String BLUE = "#437291"; + static final String BLACK = "#000000"; + static final String DARK_GRAY = "#999999"; + static final String LIGHT_GRAY = "#dddddd"; + + int fontSize(); + String fontName(); + String fontColor(); + + int arrowSize(); + int arrowWidth(); + String arrowColor(); + + default double rankSep() { + return 1; + } + + default List> ranks() { + return Collections.emptyList(); + } + + default int weightOf(String s, String t) { + return 1; + } + + default String requiresMandatedColor() { + return LIGHT_GRAY; + } + + default String javaSubgraphColor() { + return ORANGE; + } + + default String jdkSubgraphColor() { + return BLUE; + } + } + + static class DotGraphAttributes implements Attributes { + static final DotGraphAttributes DEFAULT = new DotGraphAttributes(); + + static final String FONT_NAME = "DejaVuSans"; + static final int FONT_SIZE = 12; + static final int ARROW_SIZE = 1; + static final int ARROW_WIDTH = 2; + + @Override + public int fontSize() { + return FONT_SIZE; + } + + @Override + public String fontName() { + return FONT_NAME; + } + + @Override + public String fontColor() { + return BLACK; + } + + @Override + public int arrowSize() { + return ARROW_SIZE; + } + + @Override + public int arrowWidth() { + return ARROW_WIDTH; + } + + @Override + public String arrowColor() { + return DARK_GRAY; + } + } + + private static class DotGraphBuilder { + static final String REEXPORTS = ""; + static final String REQUIRES = "style=\"dashed\""; + static final Set JAVA_SE_SUBGRAPH = javaSE(); static final Set JDK_SUBGRAPH = jdk(); @@ -215,41 +305,20 @@ } } - static final String ORANGE = "#e76f00"; - static final String BLUE = "#437291"; - static final String GRAY = "#dddddd"; - static final String BLACK = "#000000"; - - static final String FONT_NAME = "DejaVuSans"; - static final int FONT_SIZE = 12; - static final int ARROW_SIZE = 1; - static final int ARROW_WIDTH = 2; - static final int RANK_SEP = 1; - - static final String REEXPORTS = ""; - static final String REQUIRES = "style=\"dashed\""; - static final String REQUIRES_BASE = "color=\"" + GRAY + "\""; - - // can be configured - static double rankSep = RANK_SEP; - static String fontColor = BLACK; - static String fontName = FONT_NAME; - static int fontsize = FONT_SIZE; - static int arrowWidth = ARROW_WIDTH; - static int arrowSize = ARROW_SIZE; - static final Map weights = new HashMap<>(); - static final List> ranks = new ArrayList<>(); - private final String name; private final Graph graph; private final Set descriptors = new TreeSet<>(); private final List subgraphs = new ArrayList<>(); - public DotGraphBuilder(String name, Graph graph) { + private final Attributes attributes; + public DotGraphBuilder(String name, + Graph graph, + Attributes attributes) { this.name = name; this.graph = graph; + this.attributes = attributes; } - public DotGraphBuilder descriptors(Stream descriptors) { + public DotGraphBuilder modules(Stream descriptors) { descriptors.forEach(this.descriptors::add); return this; } @@ -260,22 +329,27 @@ out.format("digraph \"%s\" {%n", name); out.format(" nodesep=.5;%n"); - out.format(" ranksep=%f;%n", rankSep); + out.format(" ranksep=%f;%n", attributes.rankSep()); out.format(" pencolor=transparent;%n"); - out.format(" node [shape=plaintext, fontname=\"%s\", fontsize=%d, margin=\".2,.2\"];%n", - fontName, fontsize); - out.format(" edge [penwidth=%d, color=\"#999999\", arrowhead=open, arrowsize=%d];%n", - arrowWidth, arrowSize); + out.format(" node [shape=plaintext, fontcolor=\"%s\", fontname=\"%s\"," + + " fontsize=%d, margin=\".2,.2\"];%n", + attributes.fontColor(), + attributes.fontName(), + attributes.fontSize()); + out.format(" edge [penwidth=%d, color=\"%s\", arrowhead=open, arrowsize=%d];%n", + attributes.arrowWidth(), + attributes.arrowColor(), + attributes.arrowSize()); // same RANKS - ranks.stream() - .map(nodes -> descriptors.stream() + attributes.ranks().stream() + .map(nodes -> descriptors.stream() .map(ModuleDescriptor::name) .filter(nodes::contains) .map(mn -> "\"" + mn + "\"") .collect(joining(","))) - .filter(group -> group.length() > 0) - .forEach(group -> out.format(" {rank=same %s}%n", group)); + .filter(group -> group.length() > 0) + .forEach(group -> out.format(" {rank=same %s}%n", group)); subgraphs.forEach(subgraph -> { out.format(" subgraph %s {%n", subgraph.name); @@ -314,10 +388,14 @@ String mn = md.name(); edges.stream().forEach(dn -> { - String attr = dn.equals("java.base") ? REQUIRES_BASE - : (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES); + String attr; + if (dn.equals("java.base")) { + attr = "color=\"" + attributes.requiresMandatedColor() + "\""; + } else { + attr = (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES); + } - int w = weightOf(mn, dn); + int w = attributes.weightOf(mn, dn); if (w > 1) { if (!attr.isEmpty()) attr += ", "; @@ -328,41 +406,5 @@ }); } - public int weightOf(String s, String t) { - int w = weights.getOrDefault(s + ":" + t, 1); - if (w != 1) - return w; - if (s.startsWith("java.") && t.startsWith("java.")) - return 10; - return 1; - } - - public static void sameRankNodes(Set nodes) { - ranks.add(nodes); - } - - public static void weight(String s, String t, int w) { - weights.put(s + ":" + t, w); - } - - public static void setRankSep(double value) { - rankSep = value; - } - - public static void setFontSize(int size) { - fontsize = size; - } - - public static void setFontColor(String color) { - fontColor = color; - } - - public static void setArrowSize(int size) { - arrowSize = size; - } - - public static void setArrowWidth(int width) { - arrowWidth = width; - } } } --- old/langtools/src/jdk.jdeps/share/classes/module-info.java 2017-03-25 14:46:09.000000000 -0700 +++ new/langtools/src/jdk.jdeps/share/classes/module-info.java 2017-03-25 14:46:08.000000000 -0700 @@ -26,6 +26,7 @@ /** Defines tools for analysing dependencies in Java libraries and programs, including * the jdeps and javap tools. * + * @moduleGraph * @since 9 */ module jdk.jdeps { --- old/langtools/src/jdk.jshell/share/classes/module-info.java 2017-03-25 14:46:09.000000000 -0700 +++ new/langtools/src/jdk.jshell/share/classes/module-info.java 2017-03-25 14:46:09.000000000 -0700 @@ -52,6 +52,7 @@ * definitions. *

* + * @moduleGraph * @since 9 */ module jdk.jshell { --- /dev/null 2017-03-25 14:46:10.000000000 -0700 +++ new/jdk/make/src/classes/build/tools/taglet/ModuleGraph.java 2017-03-25 14:46:10.000000000 -0700 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2017, 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 build.tools.taglet; + +import java.util.EnumSet; +import java.util.List; +import java.util.Set; +import javax.lang.model.element.Element; +import com.sun.source.doctree.DocTree; +import jdk.javadoc.doclet.Taglet; +import static jdk.javadoc.doclet.Taglet.Location.*; + +/** + * A block tag to optionally insert a reference to a module graph. + */ +public class ModuleGraph implements Taglet { + private static final boolean enableModuleGraph = + Boolean.getBoolean("enableModuleGraph"); + + /** Returns the set of locations in which a taglet may be used. */ + @Override + public Set getAllowedLocations() { + return EnumSet.of(MODULE); + } + + @Override + public boolean isInlineTag() { + return false; + } + + @Override + public String getName() { + return "moduleGraph"; + } + + @Override + public String toString(List tags, Element element) { + if (!enableModuleGraph) { + return ""; + } + + String moduleName = element.getSimpleName().toString(); + String imageFile = moduleName + "-graph.png"; + int thumbnailHeight = -1; + String hoverImage = ""; + if (!moduleName.equals("java.base")) { + thumbnailHeight = 100; // also appears in the stylesheet + hoverImage = "" + + getImage(moduleName, imageFile, -1, true) + + ""; + } + return "
" + + "Module Graph:\n" + + "
" + + "
" + + "" + + getImage(moduleName, imageFile, thumbnailHeight, false) + + hoverImage + + "" + + "
"; + } + + private static final String VERTICAL_ALIGN = "vertical-align:top"; + private static final String BORDER = "border: solid lightgray 1px;"; + + private String getImage(String moduleName, String file, int height, boolean useBorder) { + return String.format("\"Module", + useBorder ? BORDER + " " + VERTICAL_ALIGN : VERTICAL_ALIGN, + moduleName, + file, + (height <= 0 ? "" : " height=\"" + height + "\"")); + } +} --- /dev/null 2017-03-25 14:46:10.000000000 -0700 +++ new/jdk/make/src/classes/build/tools/jigsaw/javadoc-graphs.properties 2017-03-25 14:46:10.000000000 -0700 @@ -0,0 +1,2 @@ +arrowcolor=#999999 +requiresMandatedColor=#999999