--- old/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java 2017-03-23 16:42:47.000000000 -0700 +++ new/jdk/make/src/classes/build/tools/jigsaw/GenGraphs.java 2017-03-23 16:42:46.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,8 +35,10 @@ 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.Set; @@ -67,10 +68,7 @@ System.exit(1); } - // setup and configure the dot graph attributes - initDotGraphAttributes(); Files.createDirectories(dir); - GenGraphs genGraphs = new GenGraphs(dir, spec); // print dot file for each module @@ -99,25 +97,101 @@ 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 { + final Map weights = new HashMap<>(); + final List> ranks = new ArrayList<>(); + + ModuleGraphAttributes() { + 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")); + } + + @Override + public double rankSep() { + return 0.6; + } + + @Override + public int fontSize() { + return 12; + } + + @Override + public String fontName() { + return "DejaVuSans bold"; + } + + @Override + public String fontColor() { + return BLACK; + } + + @Override + public int arrowSize() { + return 1; + } + + @Override + public int arrowWidth() { + return 2; + } + + @Override + public String arrowColor() { + return DARK_GRAY; + } + + @Override + public List> ranks() { + return ranks; + } + + @Override + public String requiresMandatedColor() { + return LIGHT_GRAY; + } + + @Override + public String javaSubgraphColor() { + return ORANGE; + } + + @Override + public String jdkSubgraphColor() { + return BLUE; + } + + @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); + } } + private static final ModuleGraphAttributes ATTRIBUTES = + new ModuleGraphAttributes(); + private final Path dir; private final boolean spec; GenGraphs(Path dir, boolean spec) { @@ -127,21 +201,17 @@ 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