< prev index next >

src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DepsAnalyzer.java

Print this page

        

@@ -26,10 +26,11 @@
 package com.sun.tools.jdeps;
 
 import com.sun.tools.classfile.Dependency.Location;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Deque;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Optional;

@@ -89,11 +90,11 @@
 
         // if -include pattern is specified, add the matching archives on
         // classpath to the root archives
         if (filter.hasIncludePattern() || filter.hasTargetFilter()) {
             configuration.getModules().values().stream()
-                .filter(source -> filter.include(source) && filter.matches(source))
+                .filter(source -> include(source) && filter.matches(source))
                 .forEach(this.rootArchives::add);
         }
 
         // class path archives
         configuration.classPathArchives().stream()

@@ -159,18 +160,18 @@
      * If --require is set, they should be excluded.
      */
     Set<Archive> archives() {
         if (filter.requiresFilter().isEmpty()) {
             return archives.stream()
-                .filter(filter::include)
+                .filter(this::include)
                 .filter(Archive::hasDependences)
                 .collect(Collectors.toSet());
         } else {
             // use the archives that have dependences and not specified in --require
             return archives.stream()
-                .filter(filter::include)
-                .filter(source -> !filter.requiresFilter().contains(source))
+                .filter(this::include)
+                .filter(source -> !filter.requiresFilter().contains(source.getName()))
                 .filter(source ->
                         source.getDependencies()
                               .map(finder::locationToArchive)
                               .anyMatch(a -> a != source))
                 .collect(Collectors.toSet());

@@ -195,11 +196,10 @@
     private Set<Archive> unresolvedArchives(Stream<Location> locations) {
         return locations.filter(l -> !finder.isParsed(l))
                         .distinct()
                         .map(configuration::findClass)
                         .flatMap(Optional::stream)
-                        .filter(filter::include)
                         .collect(toSet());
     }
 
     /*
      * Recursively analyzes entire module/archives.

@@ -236,11 +236,11 @@
             while ((target = unresolved.poll()) != null) {
                 if (finder.isParsed(target))
                     continue;
 
                 Archive archive = configuration.findClass(target).orElse(null);
-                if (archive != null && filter.include(archive)) {
+                if (archive != null) {
                     archives.add(archive);
 
                     String name = target.getName();
                     Set<Location> targets = apiOnly
                             ? finder.parseExportedAPIs(archive, name)

@@ -255,10 +255,25 @@
             unresolved = deque;
             deque = new ConcurrentLinkedDeque<>();
         } while (!unresolved.isEmpty() && depth-- > 0);
     }
 
+    /*
+     * Tests if the given archive is requested for analysis.
+     * It includes the root modules specified in --module, --add-modules
+     * or modules specified on the command line
+     *
+     * This filters system module by default unless they are explicitly
+     * requested.
+     */
+    public boolean include(Archive source) {
+        Module module = source.getModule();
+        // skip system module by default
+        return  !module.isSystem()
+                    || configuration.rootModules().contains(source);
+    }
+
     // ----- for testing purpose -----
 
     public static enum Info {
         REQUIRES,
         REQUIRES_TRANSITIVE,
< prev index next >