< prev index next >

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

Print this page




  33 import java.nio.file.Files;
  34 import java.nio.file.Path;
  35 import java.util.Collection;
  36 import java.util.Comparator;
  37 import java.util.HashMap;
  38 import java.util.Map;
  39 
  40 public abstract class JdepsWriter {
  41     public static JdepsWriter newDotWriter(Path outputdir, Analyzer.Type type) {
  42         return new DotFileWriter(outputdir, type, false, true, false);
  43     }
  44 
  45     public static JdepsWriter newSimpleWriter(PrintWriter writer,  Analyzer.Type type) {
  46         return new SimpleWriter(writer, type, false, true);
  47     }
  48 
  49     final Analyzer.Type type;
  50     final boolean showProfile;
  51     final boolean showModule;
  52 
  53     private JdepsWriter(Analyzer.Type type, boolean showProfile, boolean showModule) {
  54         this.type = type;
  55         this.showProfile = showProfile;
  56         this.showModule = showModule;
  57     }
  58 
  59     abstract void generateOutput(Collection<Archive> archives, Analyzer analyzer) throws IOException;
  60 
  61     static class DotFileWriter extends JdepsWriter {
  62         final boolean showLabel;
  63         final Path outputDir;
  64         DotFileWriter(Path dir, Analyzer.Type type,
  65                       boolean showProfile, boolean showModule, boolean showLabel) {
  66             super(type, showProfile, showModule);
  67             this.showLabel = showLabel;
  68             this.outputDir = dir;
  69         }
  70 
  71         @Override
  72         void generateOutput(Collection<Archive> archives, Analyzer analyzer)
  73                 throws IOException


 301     /**
 302      * If the given archive is JDK archive, this method returns the profile name
 303      * only if -profile option is specified; it accesses a private JDK API and
 304      * the returned value will have "JDK internal API" prefix
 305      *
 306      * For non-JDK archives, this method returns the file name of the archive.
 307      */
 308     String toTag(Archive source, String name, Archive target) {
 309         if (source == target || !target.getModule().isNamed()) {
 310             return target.getName();
 311         }
 312 
 313         Module module = target.getModule();
 314         String pn = name;
 315         if ((type == CLASS || type == VERBOSE)) {
 316             int i = name.lastIndexOf('.');
 317             pn = i > 0 ? name.substring(0, i) : "";
 318         }
 319 
 320         // exported API
 321         boolean jdkunsupported = Module.JDK_UNSUPPORTED.equals(module.name());
 322         if (module.isExported(pn) && !jdkunsupported) {
 323             return showProfileOrModule(module);
 324         }
 325 
 326         // JDK internal API
 327         if (!source.getModule().isJDK() && module.isJDK()){
 328             return "JDK internal API (" + module.name() + ")";
 329         }
 330 
 331         // qualified exports or inaccessible
 332         boolean isExported = module.isExported(pn, source.getModule().name());
 333         return module.name() + (isExported ?  " (qualified)" : " (internal)");
 334     }
 335 
 336     String showProfileOrModule(Module m) {
 337         String tag = "";
 338         if (showProfile) {
 339             Profile p = Profile.getProfile(m);
 340             if (p != null) {
 341                 tag = p.profileName();
 342             }


  33 import java.nio.file.Files;
  34 import java.nio.file.Path;
  35 import java.util.Collection;
  36 import java.util.Comparator;
  37 import java.util.HashMap;
  38 import java.util.Map;
  39 
  40 public abstract class JdepsWriter {
  41     public static JdepsWriter newDotWriter(Path outputdir, Analyzer.Type type) {
  42         return new DotFileWriter(outputdir, type, false, true, false);
  43     }
  44 
  45     public static JdepsWriter newSimpleWriter(PrintWriter writer,  Analyzer.Type type) {
  46         return new SimpleWriter(writer, type, false, true);
  47     }
  48 
  49     final Analyzer.Type type;
  50     final boolean showProfile;
  51     final boolean showModule;
  52 
  53     JdepsWriter(Analyzer.Type type, boolean showProfile, boolean showModule) {
  54         this.type = type;
  55         this.showProfile = showProfile;
  56         this.showModule = showModule;
  57     }
  58 
  59     abstract void generateOutput(Collection<Archive> archives, Analyzer analyzer) throws IOException;
  60 
  61     static class DotFileWriter extends JdepsWriter {
  62         final boolean showLabel;
  63         final Path outputDir;
  64         DotFileWriter(Path dir, Analyzer.Type type,
  65                       boolean showProfile, boolean showModule, boolean showLabel) {
  66             super(type, showProfile, showModule);
  67             this.showLabel = showLabel;
  68             this.outputDir = dir;
  69         }
  70 
  71         @Override
  72         void generateOutput(Collection<Archive> archives, Analyzer analyzer)
  73                 throws IOException


 301     /**
 302      * If the given archive is JDK archive, this method returns the profile name
 303      * only if -profile option is specified; it accesses a private JDK API and
 304      * the returned value will have "JDK internal API" prefix
 305      *
 306      * For non-JDK archives, this method returns the file name of the archive.
 307      */
 308     String toTag(Archive source, String name, Archive target) {
 309         if (source == target || !target.getModule().isNamed()) {
 310             return target.getName();
 311         }
 312 
 313         Module module = target.getModule();
 314         String pn = name;
 315         if ((type == CLASS || type == VERBOSE)) {
 316             int i = name.lastIndexOf('.');
 317             pn = i > 0 ? name.substring(0, i) : "";
 318         }
 319 
 320         // exported API
 321         if (module.isExported(pn) && !module.isJDKUnsupported()) {

 322             return showProfileOrModule(module);
 323         }
 324 
 325         // JDK internal API
 326         if (!source.getModule().isJDK() && module.isJDK()){
 327             return "JDK internal API (" + module.name() + ")";
 328         }
 329 
 330         // qualified exports or inaccessible
 331         boolean isExported = module.isExported(pn, source.getModule().name());
 332         return module.name() + (isExported ?  " (qualified)" : " (internal)");
 333     }
 334 
 335     String showProfileOrModule(Module m) {
 336         String tag = "";
 337         if (showProfile) {
 338             Profile p = Profile.getProfile(m);
 339             if (p != null) {
 340                 tag = p.profileName();
 341             }
< prev index next >