author | mchung |
Wed, 29 Mar 2017 09:40:41 -0700 | |
changeset 44417 | a431edba1629 |
parent 43808 | c0a93657773d |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
43539
b7c4265f40e7
8173604: Rename module 8173604 java.annotations.common to java.xml.ws.annoations
lancea
parents:
42708
diff
changeset
|
2 |
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
36511 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package build.tools.jigsaw; |
|
27 |
||
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
28 |
import com.sun.tools.jdeps.ModuleDotGraph; |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
29 |
|
36511 | 30 |
import java.io.IOException; |
31 |
import java.lang.module.Configuration; |
|
32 |
import java.lang.module.ModuleDescriptor; |
|
33 |
import java.lang.module.ModuleFinder; |
|
34 |
import java.lang.module.ModuleReference; |
|
35 |
import java.nio.file.Files; |
|
36 |
import java.nio.file.Path; |
|
37 |
import java.nio.file.Paths; |
|
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
38 |
import java.util.ArrayList; |
36511 | 39 |
import java.util.HashMap; |
40 |
import java.util.HashSet; |
|
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
41 |
import java.util.List; |
36511 | 42 |
import java.util.Map; |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
43 |
import java.util.Properties; |
36511 | 44 |
import java.util.Set; |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
45 |
import java.util.function.Function; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
46 |
import java.util.stream.Collectors; |
36511 | 47 |
|
48 |
/** |
|
49 |
* Generate the DOT file for a module graph for each module in the JDK |
|
50 |
* after transitive reduction. |
|
51 |
*/ |
|
52 |
public class GenGraphs { |
|
53 |
||
54 |
public static void main(String[] args) throws Exception { |
|
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
55 |
Path dir = null; |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
56 |
boolean spec = false; |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
57 |
Properties props = null; |
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
58 |
for (int i=0; i < args.length; i++) { |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
59 |
String arg = args[i]; |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
60 |
if (arg.equals("--spec")) { |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
61 |
spec = true; |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
62 |
} else if (arg.equals("--dot-attributes")) { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
63 |
if (i++ == args.length) { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
64 |
throw new IllegalArgumentException("Missing argument: --dot-attributes option"); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
65 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
66 |
props = new Properties(); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
67 |
props.load(Files.newInputStream(Paths.get(args[i]))); |
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
68 |
} else if (arg.equals("--output")) { |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
69 |
dir = ++i < args.length ? Paths.get(args[i]) : null; |
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
70 |
} else if (arg.startsWith("-")) { |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
71 |
throw new IllegalArgumentException("Invalid option: " + arg); |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
72 |
} |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
73 |
} |
36511 | 74 |
|
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
75 |
if (dir == null) { |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
76 |
System.err.println("ERROR: must specify --output argument"); |
36511 | 77 |
System.exit(1); |
78 |
} |
|
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
79 |
|
36511 | 80 |
Files.createDirectories(dir); |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
81 |
ModuleGraphAttributes attributes; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
82 |
if (props != null) { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
83 |
attributes = new ModuleGraphAttributes(props); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
84 |
} else { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
85 |
attributes = new ModuleGraphAttributes(); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
86 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
87 |
GenGraphs genGraphs = new GenGraphs(dir, spec, attributes); |
36511 | 88 |
|
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
89 |
// print dot file for each module |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
90 |
Map<String, Configuration> configurations = new HashMap<>(); |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
91 |
Set<String> modules = new HashSet<>(); |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
92 |
ModuleFinder finder = ModuleFinder.ofSystem(); |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
93 |
for (ModuleReference mref : finder.findAll()) { |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
94 |
String name = (mref.descriptor().name()); |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
95 |
modules.add(name); |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
96 |
if (genGraphs.accept(name, mref.descriptor())) { |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
97 |
configurations.put(name, Configuration.empty() |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
98 |
.resolve(finder, |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
99 |
ModuleFinder.of(), |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
100 |
Set.of(name))); |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
101 |
} |
36511 | 102 |
} |
103 |
||
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
104 |
if (genGraphs.accept("jdk", null)) { |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
105 |
// print a graph of all JDK modules |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
106 |
configurations.put("jdk", Configuration.empty() |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
107 |
.resolve(finder, |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
108 |
ModuleFinder.of(), |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
109 |
modules)); |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
110 |
} |
36511 | 111 |
|
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
112 |
genGraphs.genDotFiles(configurations); |
36511 | 113 |
} |
114 |
||
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
115 |
/** |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
116 |
* Custom dot file attributes. |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
117 |
*/ |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
118 |
static class ModuleGraphAttributes implements ModuleDotGraph.Attributes { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
119 |
static Map<String, String> DEFAULT_ATTRIBUTES = Map.of( |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
120 |
"ranksep", "0.6", |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
121 |
"fontsize", "12", |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
122 |
"fontcolor", BLACK, |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
123 |
"fontname", "DejaVuSans", |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
124 |
"arrowsize", "1", |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
125 |
"arrowwidth", "2", |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
126 |
"arrowcolor", DARK_GRAY, |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
127 |
// custom |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
128 |
"requiresMandatedColor", LIGHT_GRAY, |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
129 |
"javaSubgraphColor", ORANGE, |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
130 |
"jdkSubgraphColor", BLUE |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
131 |
); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
132 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
133 |
final Map<String, Integer> weights = new HashMap<>(); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
134 |
final List<Set<String>> ranks = new ArrayList<>(); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
135 |
final Map<String, String> attrs; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
136 |
ModuleGraphAttributes(Map<String, String> attrs) { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
137 |
int h = 1000; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
138 |
weight("java.se", "java.sql.rowset", h * 10); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
139 |
weight("java.sql.rowset", "java.sql", h * 10); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
140 |
weight("java.sql", "java.xml", h * 10); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
141 |
weight("java.xml", "java.base", h * 10); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
142 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
143 |
ranks.add(Set.of("java.logging", "java.scripting", "java.xml")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
144 |
ranks.add(Set.of("java.sql")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
145 |
ranks.add(Set.of("java.compiler", "java.instrument")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
146 |
ranks.add(Set.of("java.desktop", "java.management")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
147 |
ranks.add(Set.of("java.corba", "java.xml.ws")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
148 |
ranks.add(Set.of("java.xml.bind", "java.xml.ws.annotation")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
149 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
150 |
this.attrs = attrs; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
151 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
152 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
153 |
ModuleGraphAttributes() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
154 |
this(DEFAULT_ATTRIBUTES); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
155 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
156 |
ModuleGraphAttributes(Properties props) { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
157 |
this(toAttributes(props)); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
158 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
159 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
160 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
161 |
public double rankSep() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
162 |
return Double.valueOf(attrs.get("ranksep")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
163 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
164 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
165 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
166 |
public int fontSize() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
167 |
return Integer.valueOf(attrs.get("fontsize")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
168 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
169 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
170 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
171 |
public String fontName() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
172 |
return attrs.get("fontname"); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
173 |
} |
36511 | 174 |
|
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
175 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
176 |
public String fontColor() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
177 |
return attrs.get("fontcolor"); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
178 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
179 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
180 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
181 |
public int arrowSize() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
182 |
return Integer.valueOf(attrs.get("arrowsize")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
183 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
184 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
185 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
186 |
public int arrowWidth() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
187 |
return Integer.valueOf(attrs.get("arrowwidth")); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
188 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
189 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
190 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
191 |
public String arrowColor() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
192 |
return attrs.get("arrowcolor"); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
193 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
194 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
195 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
196 |
public List<Set<String>> ranks() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
197 |
return ranks; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
198 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
199 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
200 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
201 |
public String requiresMandatedColor() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
202 |
return attrs.get("requiresMandatedColor"); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
203 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
204 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
205 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
206 |
public String javaSubgraphColor() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
207 |
return attrs.get("javaSubgraphColor"); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
208 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
209 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
210 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
211 |
public String jdkSubgraphColor() { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
212 |
return attrs.get("jdkSubgraphColor"); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
213 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
214 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
215 |
@Override |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
216 |
public int weightOf(String s, String t) { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
217 |
int w = weights.getOrDefault(s + ":" + t, 1); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
218 |
if (w != 1) |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
219 |
return w; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
220 |
if (s.startsWith("java.") && t.startsWith("java.")) |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
221 |
return 10; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
222 |
return 1; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
223 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
224 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
225 |
public void weight(String s, String t, int w) { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
226 |
weights.put(s + ":" + t, w); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
227 |
} |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
228 |
|
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
229 |
static Map<String, String> toAttributes(Properties props) { |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
230 |
return DEFAULT_ATTRIBUTES.keySet().stream() |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
231 |
.collect(Collectors.toMap(Function.identity(), |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
232 |
k -> props.getProperty(k, DEFAULT_ATTRIBUTES.get(k)))); |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
233 |
} |
36511 | 234 |
} |
235 |
||
42701
274434f1297c
8171323: generate dot file for java.se and java.se.ee with only API dependences
mchung
parents:
42693
diff
changeset
|
236 |
private final Path dir; |
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
237 |
private final boolean spec; |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
238 |
private final ModuleGraphAttributes attributes; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
239 |
GenGraphs(Path dir, boolean spec, ModuleGraphAttributes attributes) { |
42701
274434f1297c
8171323: generate dot file for java.se and java.se.ee with only API dependences
mchung
parents:
42693
diff
changeset
|
240 |
this.dir = dir; |
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
241 |
this.spec = spec; |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
242 |
this.attributes = attributes; |
42701
274434f1297c
8171323: generate dot file for java.se and java.se.ee with only API dependences
mchung
parents:
42693
diff
changeset
|
243 |
} |
274434f1297c
8171323: generate dot file for java.se and java.se.ee with only API dependences
mchung
parents:
42693
diff
changeset
|
244 |
|
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
245 |
void genDotFiles(Map<String, Configuration> configurations) throws IOException { |
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
246 |
ModuleDotGraph dotGraph = new ModuleDotGraph(configurations, spec); |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
247 |
dotGraph.genDotFiles(dir, attributes); |
42701
274434f1297c
8171323: generate dot file for java.se and java.se.ee with only API dependences
mchung
parents:
42693
diff
changeset
|
248 |
} |
274434f1297c
8171323: generate dot file for java.se and java.se.ee with only API dependences
mchung
parents:
42693
diff
changeset
|
249 |
|
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
250 |
/** |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
251 |
* Returns true for any name if generating graph for non-spec; |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
252 |
* otherwise, returns true except "jdk" and name with "jdk.internal." prefix |
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
253 |
*/ |
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
254 |
boolean accept(String name, ModuleDescriptor descriptor) { |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
255 |
if (!spec) |
43808
c0a93657773d
8173374: Update GenGraphs tool to generate dot graph with requires transitive edges
mchung
parents:
43712
diff
changeset
|
256 |
return true; |
36511 | 257 |
|
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
258 |
return !name.equals("jdk") && !name.startsWith("jdk.internal."); |
36511 | 259 |
} |
44417
a431edba1629
8173303: Add module-subgraph images to main platform documentation
mchung
parents:
43808
diff
changeset
|
260 |
} |