changeset 4266:d8c7bf66b0e6

requirs public -> requires transitive
author mchung
date Tue, 23 Aug 2016 14:09:54 -0700
parents 77cd200ee6ed
children 73454cdf4732
files src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java
diffstat 4 files changed, 40 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java	Tue Aug 23 08:14:28 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java	Tue Aug 23 14:09:54 2016 -0700
@@ -29,11 +29,9 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Deque;
-import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedDeque;
@@ -261,7 +259,7 @@
 
     public static enum Info {
         REQUIRES,
-        REQUIRES_PUBLIC,
+        REQUIRES_TRANSITIVE,
         EXPORTED_API,
         MODULE_PRIVATE,
         QUALIFIED_EXPORTED_API,
@@ -286,7 +284,7 @@
         @Override
         public String toString() {
             StringBuilder sb = new StringBuilder();
-            if (info != Info.REQUIRES && info != Info.REQUIRES_PUBLIC)
+            if (info != Info.REQUIRES && info != Info.REQUIRES_TRANSITIVE)
                 sb.append(source).append("/");
 
             sb.append(name);
@@ -323,7 +321,7 @@
      * Returns a graph of module dependences.
      *
      * Each Node represents a module and each edge is a dependence.
-     * No analysis on "requires public".
+     * No analysis on "requires transitive".
      */
     public Graph<Node> moduleGraph() {
         Graph.Builder<Node> builder = new Graph.Builder<>();
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java	Tue Aug 23 08:14:28 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java	Tue Aug 23 14:09:54 2016 -0700
@@ -388,10 +388,10 @@
         }
 
         static void printEdges(PrintWriter out, Graph<String> graph,
-                               String node, Set<String> requiresPublic) {
+                               String node, Set<String> requiresTransitive) {
             graph.adjacentNodes(node).forEach(dn -> {
                 String attr = dn.equals("java.base") ? REQUIRES_BASE
-                        : (requiresPublic.contains(dn) ? REEXPORTS : REQUIRES);
+                        : (requiresTransitive.contains(dn) ? REEXPORTS : REQUIRES);
                 out.format("  \"%s\" -> \"%s\" [%s];%n", node, dn, attr);
             });
         }
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Tue Aug 23 08:14:28 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Tue Aug 23 14:09:54 2016 -0700
@@ -97,8 +97,8 @@
 
     public boolean run() throws IOException {
         try {
-            // compute "requires public" dependences
-            modules.values().forEach(ModuleDeps::computeRequiresPublic);
+            // compute "requires transitive" dependences
+            modules.values().forEach(ModuleDeps::computeRequiresTransitive);
 
             modules.values().forEach(md -> {
                 // compute "requires" dependences
@@ -114,7 +114,7 @@
 
     class ModuleDeps {
         final Module root;
-        Set<Module> requiresPublic;
+        Set<Module> requiresTransitive;
         Set<Module> requires;
         Map<String, Set<String>> unusedQualifiedExports;
 
@@ -123,15 +123,15 @@
         }
 
         /**
-         * Compute 'requires public' dependences by analyzing API dependencies
+         * Compute 'requires transitive' dependences by analyzing API dependencies
          */
-        private void computeRequiresPublic() {
-            // record requires public
-            this.requiresPublic = computeRequires(true)
+        private void computeRequiresTransitive() {
+            // record requires transitive
+            this.requiresTransitive = computeRequires(true)
                 .filter(m -> !m.name().equals(JAVA_BASE))
                 .collect(toSet());
 
-            trace("requires public: %s%n", requiresPublic);
+            trace("requires transitive: %s%n", requiresTransitive);
         }
 
         private void computeRequires() {
@@ -154,10 +154,10 @@
         }
 
         ModuleDescriptor descriptor() {
-            return descriptor(requiresPublic, requires);
+            return descriptor(requiresTransitive, requires);
         }
 
-        private ModuleDescriptor descriptor(Set<Module> requiresPublic,
+        private ModuleDescriptor descriptor(Set<Module> requiresTransitive,
                                             Set<Module> requires) {
 
             ModuleDescriptor.Builder builder = new ModuleDescriptor.Builder(root.name());
@@ -165,13 +165,13 @@
             if (!root.name().equals(JAVA_BASE))
                 builder.requires(Set.of(MANDATED), JAVA_BASE);
 
-            requiresPublic.stream()
+            requiresTransitive.stream()
                 .filter(m -> !m.name().equals(JAVA_BASE))
                 .map(Module::name)
                 .forEach(mn -> builder.requires(Set.of(TRANSITIVE), mn));
 
             requires.stream()
-                .filter(m -> !requiresPublic.contains(m))
+                .filter(m -> !requiresTransitive.contains(m))
                 .filter(m -> !m.name().equals(JAVA_BASE))
                 .map(Module::name)
                 .forEach(mn -> builder.requires(mn));
@@ -181,13 +181,13 @@
 
         ModuleDescriptor reduced() {
             Graph.Builder<Module> bd = new Graph.Builder<>();
-            requiresPublic.stream()
+            requiresTransitive.stream()
                 .forEach(m -> {
                     bd.addNode(m);
                     bd.addEdge(root, m);
                 });
 
-            // requires public graph
+            // requires transitive graph
             Graph<Module> rbg = bd.build().reduce();
 
             // transitive reduction
@@ -197,7 +197,7 @@
                 newGraph.printGraph(log);
             }
 
-            return descriptor(requiresPublic, newGraph.adjacentNodes(root));
+            return descriptor(requiresTransitive, newGraph.adjacentNodes(root));
         }
 
 
@@ -207,14 +207,14 @@
          */
         private void analyzeDeps() {
             Graph.Builder<Module> builder = new Graph.Builder<>();
-            requiresPublic.stream()
+            requiresTransitive.stream()
                 .forEach(m -> {
                     builder.addNode(m);
                     builder.addEdge(root, m);
                 });
 
-            // requires public graph
-            Graph<Module> rbg = buildGraph(requiresPublic).reduce();
+            // requires transitive graph
+            Graph<Module> rbg = buildGraph(requiresTransitive).reduce();
 
             // transitive reduction
             Graph<Module> newGraph = buildGraph(requires).reduce(builder.build().reduce());
@@ -279,7 +279,7 @@
         /**
          * Returns a graph of modules required by the specified module.
          *
-         * Requires public edges of the dependences are added to the graph.
+         * Requires transitive edges of the dependences are added to the graph.
          */
         private Graph<Module> buildGraph(Set<Module> deps) {
             Graph.Builder<Module> builder = new Graph.Builder<>();
@@ -293,7 +293,7 @@
                     builder.addEdge(root, m);
                 });
 
-            // read requires public from ModuleDescription
+            // read requires transitive from ModuleDescription
             Module source;
             while ((source = deque.poll()) != null) {
                 if (visited.contains(source))
@@ -365,7 +365,7 @@
     }
 
     private boolean matches(ModuleDescriptor md, ModuleDescriptor other) {
-        // build requires public from ModuleDescriptor
+        // build requires transitive from ModuleDescriptor
         Set<ModuleDescriptor.Requires> reqPublic = md.requires().stream()
             .filter(req -> req.modifiers().contains(TRANSITIVE))
             .collect(toSet());
@@ -374,7 +374,7 @@
             .collect(toSet());
 
         if (!reqPublic.equals(otherReqPublic)) {
-            trace("mismatch requires public: %s%n", reqPublic);
+            trace("mismatch requires transitive: %s%n", reqPublic);
             return false;
         }
 
@@ -421,12 +421,12 @@
                 .sorted(Comparator.comparing(ModuleDescriptor::name))
                 .forEach(md -> {
                     String mn = md.name();
-                    Set<String> requiresPublic = md.requires().stream()
+                    Set<String> requiresTransitive = md.requires().stream()
                         .filter(d -> d.modifiers().contains(TRANSITIVE))
                         .map(d -> d.name())
                         .collect(toSet());
 
-                    DotGraph.printEdges(out, graph, mn, requiresPublic);
+                    DotGraph.printEdges(out, graph, mn, requiresTransitive);
                 });
 
             out.println("}");
@@ -436,13 +436,13 @@
     /**
      * Returns a Graph of the given Configuration after transitive reduction.
      *
-     * Transitive reduction of requires public edge and requires edge have
-     * to be applied separately to prevent the requires public edges
+     * Transitive reduction of requires transitive edge and requires edge have
+     * to be applied separately to prevent the requires transitive edges
      * (e.g. U -> V) from being reduced by a path (U -> X -> Y -> V)
      * in which  V would not be re-exported from U.
      */
     private Graph<String> gengraph(Set<Module> modules) {
-        // build a Graph containing only requires public edges
+        // build a Graph containing only requires transitive edges
         // with transitive reduction.
         Graph.Builder<String> rpgbuilder = new Graph.Builder<>();
         for (Module module : modules) {
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java	Tue Aug 23 08:14:28 2016 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java	Tue Aug 23 14:09:54 2016 -0700
@@ -96,7 +96,7 @@
     public boolean run() throws IOException {
         try {
             // pass 1: find API dependencies
-            Map<Archive, Set<Archive>> requiresPublic = computeRequiresPublic();
+            Map<Archive, Set<Archive>> requiresTransitive = computeRequiresTransitive();
 
             // pass 2: analyze all class dependences
             dependencyFinder.parse(automaticModules().stream());
@@ -105,13 +105,13 @@
 
             boolean missingDeps = false;
             for (Module m : automaticModules()) {
-                Set<Archive> apiDeps = requiresPublic.containsKey(m)
-                                            ? requiresPublic.get(m)
+                Set<Archive> apiDeps = requiresTransitive.containsKey(m)
+                                            ? requiresTransitive.get(m)
                                             : Collections.emptySet();
 
                 Path file = outputdir.resolve(m.name()).resolve("module-info.java");
 
-                // computes requires and requires public
+                // computes requires and requires transitive
                 Module explicitModule = toExplicitModule(m, apiDeps);
                 if (explicitModule != null) {
                     automaticToExplicitModule.put(m, explicitModule);
@@ -136,7 +136,7 @@
         return m == NOT_FOUND || m == REMOVED_JDK_INTERNALS;
     }
 
-    private Module toExplicitModule(Module module, Set<Archive> requiresPublic)
+    private Module toExplicitModule(Module module, Set<Archive> requiresTransitive)
         throws IOException
     {
         // done analysis
@@ -148,7 +148,7 @@
         }
 
         Map<String, Boolean> requires = new HashMap<>();
-        requiresPublic.stream()
+        requiresTransitive.stream()
             .map(Archive::getModule)
             .forEach(m -> requires.put(m.name(), Boolean.TRUE));
 
@@ -227,9 +227,9 @@
     }
 
     /**
-     * Compute 'requires public' dependences by analyzing API dependencies
+     * Compute 'requires transitive' dependences by analyzing API dependencies
      */
-    private Map<Archive, Set<Archive>> computeRequiresPublic() throws IOException {
+    private Map<Archive, Set<Archive>> computeRequiresTransitive() throws IOException {
         // parse the input modules
         dependencyFinder.parseExportedAPIs(automaticModules().stream());