< prev index next >

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

Print this page




 369                     case "-filter:archive":
 370                     case "-filter:module":
 371                         task.options.filterSameArchive = true;
 372                         task.options.filterSamePackage = false;
 373                         break;
 374                     case "-filter:none":
 375                         task.options.filterSameArchive = false;
 376                         task.options.filterSamePackage = false;
 377                         break;
 378                 }
 379             }
 380         },
 381 
 382         // ---- Source filtering options ----
 383         new Option(true, "-include") {
 384             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 385                 task.options.includePattern = Pattern.compile(arg);
 386             }
 387         },
 388 
 389         // Another alternative to list modules in --add-modules option
 390         new HiddenOption(true, "--include-system-modules") {
 391             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 392                 task.options.includeSystemModulePattern = Pattern.compile(arg);
 393             }
 394         },
 395 
 396         new Option(false, "-P", "-profile") {
 397             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 398                 task.options.showProfile = true;
 399             }
 400         },
 401 
 402         new Option(false, "-R", "-recursive") {
 403             void process(JdepsTask task, String opt, String arg) {
 404                 task.options.depth = 0;
 405                 // turn off filtering
 406                 task.options.filterSameArchive = false;
 407                 task.options.filterSamePackage = false;
 408             }
 409         },
 410 
 411         new Option(false, "-I", "--inverse") {
 412             void process(JdepsTask task, String opt, String arg) {
 413                 task.options.inverse = true;
 414                 // equivalent to the inverse of compile-time view analysis
 415                 task.options.compileTimeView = true;


1004 
1005             Type type = getAnalyzerType();
1006             JdepsWriter writer = new DotFileWriter(dotOutputDir,
1007                                                    type,
1008                                                    options.showProfile,
1009                                                    options.showModule,
1010                                                    options.showLabel);
1011             return run(config, writer, type);
1012         }
1013     }
1014 
1015     /**
1016      * Returns a filter used during dependency analysis
1017      */
1018     private JdepsFilter dependencyFilter(JdepsConfiguration config) {
1019         // Filter specified by -filter, -package, -regex, and --require options
1020         JdepsFilter.Builder builder = new JdepsFilter.Builder();
1021 
1022         // source filters
1023         builder.includePattern(options.includePattern);
1024         builder.includeSystemModules(options.includeSystemModulePattern);
1025 

1026         builder.filter(options.filterSamePackage, options.filterSameArchive);
1027         builder.findJDKInternals(options.findJDKInternals);
1028 
1029         // --require
1030         if (!options.requires.isEmpty()) {
1031             options.requires.stream()
1032                 .forEach(mn -> {
1033                     Module m = config.findModule(mn).get();
1034                     builder.requires(mn, m.packages());
1035                 });
1036         }
1037         // -regex
1038         if (options.regex != null)
1039             builder.regex(options.regex);
1040         // -package
1041         if (!options.packageNames.isEmpty())
1042             builder.packages(options.packageNames);
1043         // -filter
1044         if (options.filterRegex != null)
1045             builder.filter(options.filterRegex);
1046 
1047         // check if system module is set
1048         config.rootModules().stream()
1049               .map(Module::name)
1050               .forEach(builder::includeIfSystemModule);
1051 
1052         return builder.build();
1053     }
1054 
1055     public void handleOptions(String[] args) throws BadArgs {
1056         // process options
1057         for (int i=0; i < args.length; i++) {
1058             if (args[i].charAt(0) == '-') {
1059                 String name = args[i];
1060                 Option option = getOption(name);
1061                 String param = null;
1062                 if (option.hasArg) {
1063                     if (name.startsWith("-") && name.indexOf('=') > 0) {
1064                         param = name.substring(name.indexOf('=') + 1, name.length());
1065                     } else if (i + 1 < args.length) {
1066                         param = args[++i];
1067                     }
1068                     if (param == null || param.isEmpty() || param.charAt(0) == '-') {
1069                         throw new BadArgs("err.missing.arg", name).showUsage(true);
1070                     }
1071                 }


1145         boolean version;
1146         boolean fullVersion;
1147         boolean showProfile;
1148         boolean showModule = true;
1149         boolean showSummary;
1150         boolean apiOnly;
1151         boolean showLabel;
1152         boolean findJDKInternals;
1153         boolean nowarning = false;
1154         Analyzer.Type verbose;
1155         // default filter references from same package
1156         boolean filterSamePackage = true;
1157         boolean filterSameArchive = false;
1158         Pattern filterRegex;
1159         String classpath;
1160         int depth = 1;
1161         Set<String> requires = new HashSet<>();
1162         Set<String> packageNames = new HashSet<>();
1163         Pattern regex;             // apply to the dependences
1164         Pattern includePattern;
1165         Pattern includeSystemModulePattern;
1166         boolean inverse = false;
1167         boolean compileTimeView = false;
1168         String systemModulePath = System.getProperty("java.home");
1169         String upgradeModulePath;
1170         String modulePath;
1171         String rootModule;
1172         Set<String> addmods = new HashSet<>();
1173         Runtime.Version multiRelease;
1174 
1175         boolean hasSourcePath() {
1176             return !addmods.isEmpty() || includePattern != null ||
1177                         includeSystemModulePattern != null;
1178         }
1179 
1180         boolean hasFilter() {
1181             return numFilters() > 0;
1182         }
1183 
1184         int numFilters() {
1185             int count = 0;
1186             if (requires.size() > 0) count++;
1187             if (regex != null) count++;
1188             if (packageNames.size() > 0) count++;
1189             return count;
1190         }
1191     }
1192 
1193     private static class ResourceBundleHelper {
1194         static final ResourceBundle versionRB;
1195         static final ResourceBundle bundle;
1196         static final ResourceBundle jdkinternals;
1197 




 369                     case "-filter:archive":
 370                     case "-filter:module":
 371                         task.options.filterSameArchive = true;
 372                         task.options.filterSamePackage = false;
 373                         break;
 374                     case "-filter:none":
 375                         task.options.filterSameArchive = false;
 376                         task.options.filterSamePackage = false;
 377                         break;
 378                 }
 379             }
 380         },
 381 
 382         // ---- Source filtering options ----
 383         new Option(true, "-include") {
 384             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 385                 task.options.includePattern = Pattern.compile(arg);
 386             }
 387         },
 388 







 389         new Option(false, "-P", "-profile") {
 390             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 391                 task.options.showProfile = true;
 392             }
 393         },
 394 
 395         new Option(false, "-R", "-recursive") {
 396             void process(JdepsTask task, String opt, String arg) {
 397                 task.options.depth = 0;
 398                 // turn off filtering
 399                 task.options.filterSameArchive = false;
 400                 task.options.filterSamePackage = false;
 401             }
 402         },
 403 
 404         new Option(false, "-I", "--inverse") {
 405             void process(JdepsTask task, String opt, String arg) {
 406                 task.options.inverse = true;
 407                 // equivalent to the inverse of compile-time view analysis
 408                 task.options.compileTimeView = true;


 997 
 998             Type type = getAnalyzerType();
 999             JdepsWriter writer = new DotFileWriter(dotOutputDir,
1000                                                    type,
1001                                                    options.showProfile,
1002                                                    options.showModule,
1003                                                    options.showLabel);
1004             return run(config, writer, type);
1005         }
1006     }
1007 
1008     /**
1009      * Returns a filter used during dependency analysis
1010      */
1011     private JdepsFilter dependencyFilter(JdepsConfiguration config) {
1012         // Filter specified by -filter, -package, -regex, and --require options
1013         JdepsFilter.Builder builder = new JdepsFilter.Builder();
1014 
1015         // source filters
1016         builder.includePattern(options.includePattern);

1017 
1018         // target filters
1019         builder.filter(options.filterSamePackage, options.filterSameArchive);
1020         builder.findJDKInternals(options.findJDKInternals);
1021 
1022         // --require
1023         if (!options.requires.isEmpty()) {
1024             options.requires.stream()
1025                 .forEach(mn -> {
1026                     Module m = config.findModule(mn).get();
1027                     builder.requires(mn, m.packages());
1028                 });
1029         }
1030         // -regex
1031         if (options.regex != null)
1032             builder.regex(options.regex);
1033         // -package
1034         if (!options.packageNames.isEmpty())
1035             builder.packages(options.packageNames);
1036         // -filter
1037         if (options.filterRegex != null)
1038             builder.filter(options.filterRegex);
1039 





1040         return builder.build();
1041     }
1042 
1043     public void handleOptions(String[] args) throws BadArgs {
1044         // process options
1045         for (int i=0; i < args.length; i++) {
1046             if (args[i].charAt(0) == '-') {
1047                 String name = args[i];
1048                 Option option = getOption(name);
1049                 String param = null;
1050                 if (option.hasArg) {
1051                     if (name.startsWith("-") && name.indexOf('=') > 0) {
1052                         param = name.substring(name.indexOf('=') + 1, name.length());
1053                     } else if (i + 1 < args.length) {
1054                         param = args[++i];
1055                     }
1056                     if (param == null || param.isEmpty() || param.charAt(0) == '-') {
1057                         throw new BadArgs("err.missing.arg", name).showUsage(true);
1058                     }
1059                 }


1133         boolean version;
1134         boolean fullVersion;
1135         boolean showProfile;
1136         boolean showModule = true;
1137         boolean showSummary;
1138         boolean apiOnly;
1139         boolean showLabel;
1140         boolean findJDKInternals;
1141         boolean nowarning = false;
1142         Analyzer.Type verbose;
1143         // default filter references from same package
1144         boolean filterSamePackage = true;
1145         boolean filterSameArchive = false;
1146         Pattern filterRegex;
1147         String classpath;
1148         int depth = 1;
1149         Set<String> requires = new HashSet<>();
1150         Set<String> packageNames = new HashSet<>();
1151         Pattern regex;             // apply to the dependences
1152         Pattern includePattern;

1153         boolean inverse = false;
1154         boolean compileTimeView = false;
1155         String systemModulePath = System.getProperty("java.home");
1156         String upgradeModulePath;
1157         String modulePath;
1158         String rootModule;
1159         Set<String> addmods = new HashSet<>();
1160         Runtime.Version multiRelease;
1161 
1162         boolean hasSourcePath() {
1163             return !addmods.isEmpty() || includePattern != null;

1164         }
1165 
1166         boolean hasFilter() {
1167             return numFilters() > 0;
1168         }
1169 
1170         int numFilters() {
1171             int count = 0;
1172             if (requires.size() > 0) count++;
1173             if (regex != null) count++;
1174             if (packageNames.size() > 0) count++;
1175             return count;
1176         }
1177     }
1178 
1179     private static class ResourceBundleHelper {
1180         static final ResourceBundle versionRB;
1181         static final ResourceBundle bundle;
1182         static final ResourceBundle jdkinternals;
1183 


< prev index next >