author | serb |
Sat, 09 Jun 2018 13:33:35 -0700 | |
changeset 50647 | a98ff7c2103d |
parent 47357 | 74700c8e39e9 |
child 52650 | c16b6cc93272 |
permissions | -rw-r--r-- |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
1 |
/* |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
4 |
* |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
10 |
* |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
15 |
* accompanied this code). |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
16 |
* |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
20 |
* |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
23 |
* questions. |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
24 |
*/ |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
25 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
26 |
package com.sun.tools.jdeps; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
27 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
28 |
import java.io.IOException; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
29 |
import java.io.PrintWriter; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
30 |
import java.lang.module.ModuleDescriptor; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
31 |
import java.util.Comparator; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
32 |
import java.util.HashMap; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
33 |
import java.util.HashSet; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
34 |
import java.util.Map; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
35 |
import java.util.Set; |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
36 |
import java.util.TreeSet; |
41998
feae61dc2280
8169606: jdeps --list-reduced-deps should not show java.base as all modules require it
mchung
parents:
41860
diff
changeset
|
37 |
import java.util.stream.Collectors; |
43026
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
38 |
import java.util.stream.Stream; |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
39 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
40 |
/** |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
41 |
* Analyze module dependences and any reference to JDK internal APIs. |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
42 |
* It can apply transition reduction on the resulting module graph. |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
43 |
* |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
44 |
* The result prints one line per module it depends on |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
45 |
* one line per JDK internal API package it references: |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
46 |
* $MODULE[/$PACKAGE] |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
47 |
* |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
48 |
*/ |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
49 |
public class ModuleExportsAnalyzer extends DepsAnalyzer { |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
50 |
// source archive to its dependences and JDK internal APIs it references |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
51 |
private final Map<Archive, Map<Archive,Set<String>>> deps = new HashMap<>(); |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
52 |
private final boolean showJdkInternals; |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
53 |
private final boolean reduced; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
54 |
private final PrintWriter writer; |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
55 |
private final String separator; |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
56 |
public ModuleExportsAnalyzer(JdepsConfiguration config, |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
57 |
JdepsFilter filter, |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
58 |
boolean showJdkInternals, |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
59 |
boolean reduced, |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
60 |
PrintWriter writer, |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
61 |
String separator) { |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
62 |
super(config, filter, null, |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
63 |
Analyzer.Type.PACKAGE, |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
64 |
false /* all classes */); |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
65 |
this.showJdkInternals = showJdkInternals; |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
66 |
this.reduced = reduced; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
67 |
this.writer = writer; |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
68 |
this.separator = separator; |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
69 |
} |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
70 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
71 |
@Override |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
72 |
public boolean run() throws IOException { |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
73 |
// analyze dependences |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
74 |
boolean rc = super.run(); |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
75 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
76 |
// A visitor to record the module-level dependences as well as |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
77 |
// use of JDK internal APIs |
42827
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42407
diff
changeset
|
78 |
Analyzer.Visitor visitor = (origin, originArchive, target, targetArchive) -> { |
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42407
diff
changeset
|
79 |
Set<String> jdkInternals = |
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42407
diff
changeset
|
80 |
deps.computeIfAbsent(originArchive, _k -> new HashMap<>()) |
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42407
diff
changeset
|
81 |
.computeIfAbsent(targetArchive, _k -> new HashSet<>()); |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
82 |
|
42827
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42407
diff
changeset
|
83 |
Module module = targetArchive.getModule(); |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
84 |
if (showJdkInternals && originArchive.getModule() != module && |
42827
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42407
diff
changeset
|
85 |
module.isJDK() && !module.isExported(target)) { |
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42407
diff
changeset
|
86 |
// use of JDK internal APIs |
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42407
diff
changeset
|
87 |
jdkInternals.add(target); |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
88 |
} |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
89 |
}; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
90 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
91 |
// visit the dependences |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
92 |
archives.stream() |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
93 |
.filter(analyzer::hasDependences) |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
94 |
.sorted(Comparator.comparing(Archive::getName)) |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
95 |
.forEach(archive -> analyzer.visitDependences(archive, visitor)); |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
96 |
|
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
97 |
Set<Module> modules = modules(); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
98 |
if (showJdkInternals) { |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
99 |
// print modules and JDK internal API dependences |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
100 |
printDependences(modules); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
101 |
} else { |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
102 |
// print module dependences |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
103 |
writer.println(modules.stream().map(Module::name).sorted() |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
104 |
.collect(Collectors.joining(separator))); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
105 |
} |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
106 |
return rc; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
107 |
} |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
108 |
|
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
109 |
private Set<Module> modules() { |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
110 |
// build module graph |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
111 |
ModuleGraphBuilder builder = new ModuleGraphBuilder(configuration); |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
112 |
Module root = new RootModule("root"); |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
113 |
builder.addModule(root); |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
114 |
// find named module dependences |
43026
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
115 |
dependenceStream() |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
116 |
.flatMap(map -> map.keySet().stream()) |
43026
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
117 |
.filter(m -> m.getModule().isNamed() |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
118 |
&& !configuration.rootModules().contains(m)) |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
119 |
.map(Archive::getModule) |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
120 |
.forEach(m -> builder.addEdge(root, m)); |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
121 |
|
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
122 |
// build module dependence graph |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
123 |
// if reduced is set, apply transition reduction |
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
124 |
Graph<Module> g = reduced ? builder.reduced() : builder.build(); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
125 |
return g.adjacentNodes(root); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
126 |
} |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
127 |
|
47357
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
128 |
private void printDependences(Set<Module> modules) { |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
129 |
// find use of JDK internals |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
130 |
Map<Module, Set<String>> jdkinternals = new HashMap<>(); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
131 |
dependenceStream() |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
132 |
.flatMap(map -> map.entrySet().stream()) |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
133 |
.filter(e -> e.getValue().size() > 0) |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
134 |
.forEach(e -> jdkinternals.computeIfAbsent(e.getKey().getModule(), |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
135 |
_k -> new TreeSet<>()) |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
136 |
.addAll(e.getValue())); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
137 |
|
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
138 |
// print modules and JDK internal API dependences |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
139 |
Stream.concat(modules.stream(), jdkinternals.keySet().stream()) |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
140 |
.sorted(Comparator.comparing(Module::name)) |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
141 |
.distinct() |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
142 |
.forEach(m -> { |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
143 |
if (jdkinternals.containsKey(m)) { |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
144 |
jdkinternals.get(m).stream() |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
145 |
.forEach(pn -> writer.format(" %s/%s%s", m, pn, separator)); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
146 |
} else { |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
147 |
writer.format(" %s%s", m, separator); |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
148 |
} |
74700c8e39e9
8189202: (jdeps) Need jdeps output format easy for jlink --add-modules to use
mchung
parents:
47216
diff
changeset
|
149 |
}); |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
150 |
} |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
151 |
|
43026
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
152 |
/* |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
153 |
* Returns a stream of dependence map from an Archive to the set of JDK |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
154 |
* internal APIs being used. |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
155 |
*/ |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
156 |
private Stream<Map<Archive, Set<String>>> dependenceStream() { |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
157 |
return deps.keySet().stream() |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
158 |
.filter(source -> !source.getModule().isNamed() |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
159 |
|| configuration.rootModules().contains(source)) |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
160 |
.map(deps::get); |
8e8b50c7491d
8172212: jdeps --require and --check should detect the specified module in the image
mchung
parents:
42827
diff
changeset
|
161 |
} |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
162 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
163 |
private class RootModule extends Module { |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
164 |
final ModuleDescriptor descriptor; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
165 |
RootModule(String name) { |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
166 |
super(name); |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
167 |
|
43767
9cff98a149cb
8173393: Module system implementation refresh (2/2017)
alanb
parents:
43026
diff
changeset
|
168 |
ModuleDescriptor.Builder builder = ModuleDescriptor.newModule(name); |
41860
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
169 |
this.descriptor = builder.build(); |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
170 |
} |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
171 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
172 |
@Override |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
173 |
public ModuleDescriptor descriptor() { |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
174 |
return descriptor; |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
175 |
} |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
176 |
} |
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
177 |
|
906670ff49c7
8167057: jdeps option to list modules and internal APIs for @modules for test dev
mchung
parents:
diff
changeset
|
178 |
} |