< prev index next >

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

Print this page




 217                     default:
 218                         throw new BadArgs("err.invalid.arg.for.option", opt);
 219                 }
 220             }
 221         },
 222         new Option(false, "-apionly", "--api-only") {
 223             void process(JdepsTask task, String opt, String arg) {
 224                 task.options.apiOnly = true;
 225             }
 226         },
 227 
 228         new Option(false, "-jdkinternals", "--jdk-internals") {
 229             void process(JdepsTask task, String opt, String arg) {
 230                 task.options.findJDKInternals = true;
 231                 if (task.options.includePattern == null) {
 232                     task.options.includePattern = Pattern.compile(".*");
 233                 }
 234             }
 235         },
 236 
 237         new Option(true, CommandOption.CHECK_MODULES) {
 238             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 239                 if (task.command != null) {
 240                     throw new BadArgs("err.command.set", task.command, opt);
 241                 }
 242                 Set<String> mods =  Set.of(arg.split(","));
 243                 task.options.addmods.addAll(mods);
 244                 task.command = task.checkModuleDeps(mods);
 245             }
 246         },
 247         new Option(true, CommandOption.GENERATE_MODULE_INFO) {
 248             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 249                 if (task.command != null) {
 250                     throw new BadArgs("err.command.set", task.command, opt);
 251                 }
 252                 task.command = task.genModuleInfo(Paths.get(arg), false);
 253             }
 254         },
 255         new Option(true, CommandOption.GENERATE_OPEN_MODULE) {
 256             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 257                 if (task.command != null) {
 258                     throw new BadArgs("err.command.set", task.command, opt);
 259                 }
 260                 task.command = task.genModuleInfo(Paths.get(arg), true);
 261             }
 262         },
 263         new Option(false, CommandOption.LIST_DEPS) {
 264             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 265                 if (task.command != null) {
 266                     throw new BadArgs("err.command.set", task.command, opt);
 267                 }
 268                 task.command = task.listModuleDeps(false);
 269             }
 270         },
 271         new Option(false, CommandOption.LIST_REDUCED_DEPS) {
 272             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 273                 if (task.command != null) {
 274                     throw new BadArgs("err.command.set", task.command, opt);
 275                 }
 276                 task.command = task.listModuleDeps(true);
 277             }
 278         },
 279 
 280         // ---- paths option ----
 281         new Option(true, "-cp", "-classpath", "--class-path") {
 282             void process(JdepsTask task, String opt, String arg) {
 283                 task.options.classpath = arg;
 284             }
 285         },
 286         new Option(true, "--module-path") {
 287             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 288                 task.options.modulePath = arg;
 289             }
 290         },
 291         new Option(true, "--upgrade-module-path") {
 292             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 293                 task.options.upgradeModulePath = arg;
 294             }
 295         },
 296         new Option(true, "--system") {
 297             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 298                 if (arg.equals("none")) {
 299                     task.options.systemModulePath = null;
 300                 } else {
 301                     Path path = Paths.get(arg);
 302                     if (Files.isRegularFile(path.resolve("lib").resolve("modules")))
 303                         task.options.systemModulePath = arg;
 304                     else
 305                         throw new BadArgs("err.invalid.path", arg);
 306                 }
 307             }
 308         },
 309         new Option(true, "--add-modules") {
 310             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 311                 Set<String> mods = Set.of(arg.split(","));
 312                 task.options.addmods.addAll(mods);
 313             }
 314         },
 315         new Option(true, "-m", "--module") {
 316             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 317                 if (!task.options.rootModules.isEmpty()) {
 318                     throw new BadArgs("err.option.already.specified", opt);
 319                 }
 320                 task.options.rootModules.add(arg);
 321                 task.options.addmods.add(arg);
 322             }
 323         },
 324         new Option(true, "--multi-release") {
 325             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 326                 if (arg.equalsIgnoreCase("base")) {
 327                     task.options.multiRelease = JarFile.baseVersion();
 328                 } else {
 329                     try {
 330                         int v = Integer.parseInt(arg);
 331                         if (v < 9) {
 332                             throw new BadArgs("err.invalid.arg.for.option", arg);
 333                         }
 334                     } catch (NumberFormatException x) {
 335                         throw new BadArgs("err.invalid.arg.for.option", arg);
 336                     }
 337                     task.options.multiRelease = Runtime.Version.parse(arg);
 338                 }
 339             }
 340         },
































































 341 
 342         // ---- Target filtering options ----
 343         new Option(true, "-p", "-package", "--package") {
 344             void process(JdepsTask task, String opt, String arg) {
 345                 task.options.packageNames.add(arg);
 346             }
 347         },
 348         new Option(true, "-e", "-regex", "--regex") {
 349             void process(JdepsTask task, String opt, String arg) {
 350                 task.options.regex = Pattern.compile(arg);
 351             }
 352         },
 353         new Option(true, "--require") {
 354             void process(JdepsTask task, String opt, String arg) {
 355                 task.options.requires.add(arg);
 356                 task.options.addmods.add(arg);
 357             }
 358         },
 359         new Option(true, "-f", "-filter") {
 360             void process(JdepsTask task, String opt, String arg) {


 407 
 408         new Option(false, "-I", "--inverse") {
 409             void process(JdepsTask task, String opt, String arg) {
 410                 task.options.inverse = true;
 411                 // equivalent to the inverse of compile-time view analysis
 412                 task.options.compileTimeView = true;
 413                 task.options.filterSamePackage = true;
 414                 task.options.filterSameArchive = true;
 415             }
 416         },
 417 
 418         new Option(false, "--compile-time") {
 419             void process(JdepsTask task, String opt, String arg) {
 420                 task.options.compileTimeView = true;
 421                 task.options.filterSamePackage = true;
 422                 task.options.filterSameArchive = true;
 423                 task.options.depth = 0;
 424             }
 425         },
 426 
 427         new Option(false, "-q", "-quiet") {
 428             void process(JdepsTask task, String opt, String arg) {
 429                 task.options.nowarning = true;
 430             }
 431         },
 432 
 433         new Option(false, "-version", "--version") {
 434             void process(JdepsTask task, String opt, String arg) {
 435                 task.options.version = true;
 436             }
 437         },
 438         new HiddenOption(false, "-fullversion") {
 439             void process(JdepsTask task, String opt, String arg) {
 440                 task.options.fullVersion = true;
 441             }
 442         },
 443         new HiddenOption(false, "-showlabel") {
 444             void process(JdepsTask task, String opt, String arg) {
 445                 task.options.showLabel = true;
 446             }
 447         },
 448         new HiddenOption(false, "--hide-show-module") {
 449             void process(JdepsTask task, String opt, String arg) {
 450                 task.options.showModule = false;
 451             }
 452         },
 453         new HiddenOption(true, "-depth") {
 454             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 455                 try {
 456                     task.options.depth = Integer.parseInt(arg);
 457                 } catch (NumberFormatException e) {




 217                     default:
 218                         throw new BadArgs("err.invalid.arg.for.option", opt);
 219                 }
 220             }
 221         },
 222         new Option(false, "-apionly", "--api-only") {
 223             void process(JdepsTask task, String opt, String arg) {
 224                 task.options.apiOnly = true;
 225             }
 226         },
 227 
 228         new Option(false, "-jdkinternals", "--jdk-internals") {
 229             void process(JdepsTask task, String opt, String arg) {
 230                 task.options.findJDKInternals = true;
 231                 if (task.options.includePattern == null) {
 232                     task.options.includePattern = Pattern.compile(".*");
 233                 }
 234             }
 235         },
 236 











































 237         // ---- paths option ----
 238         new Option(true, "-cp", "-classpath", "--class-path") {
 239             void process(JdepsTask task, String opt, String arg) {
 240                 task.options.classpath = arg;
 241             }
 242         },
 243         new Option(true, "--module-path") {
 244             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 245                 task.options.modulePath = arg;
 246             }
 247         },
 248         new Option(true, "--upgrade-module-path") {
 249             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 250                 task.options.upgradeModulePath = arg;
 251             }
 252         },
 253         new Option(true, "--system") {
 254             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 255                 if (arg.equals("none")) {
 256                     task.options.systemModulePath = null;
 257                 } else {
 258                     Path path = Paths.get(arg);
 259                     if (Files.isRegularFile(path.resolve("lib").resolve("modules")))
 260                         task.options.systemModulePath = arg;
 261                     else
 262                         throw new BadArgs("err.invalid.path", arg);
 263                 }
 264             }
 265         },
 266         new Option(true, "--add-modules") {
 267             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 268                 Set<String> mods = Set.of(arg.split(","));
 269                 task.options.addmods.addAll(mods);
 270             }
 271         },









 272         new Option(true, "--multi-release") {
 273             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 274                 if (arg.equalsIgnoreCase("base")) {
 275                     task.options.multiRelease = JarFile.baseVersion();
 276                 } else {
 277                     try {
 278                         int v = Integer.parseInt(arg);
 279                         if (v < 9) {
 280                             throw new BadArgs("err.invalid.arg.for.option", arg);
 281                         }
 282                     } catch (NumberFormatException x) {
 283                         throw new BadArgs("err.invalid.arg.for.option", arg);
 284                     }
 285                     task.options.multiRelease = Runtime.Version.parse(arg);
 286                 }
 287             }
 288         },
 289         new Option(false, "-q", "-quiet") {
 290             void process(JdepsTask task, String opt, String arg) {
 291                 task.options.nowarning = true;
 292             }
 293         },
 294         new Option(false, "-version", "--version") {
 295             void process(JdepsTask task, String opt, String arg) {
 296                 task.options.version = true;
 297             }
 298         },
 299 
 300         // ---- module-specific options ----
 301 
 302         new Option(true, "-m", "--module") {
 303             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 304                 if (!task.options.rootModules.isEmpty()) {
 305                     throw new BadArgs("err.option.already.specified", opt);
 306                 }
 307                 task.options.rootModules.add(arg);
 308                 task.options.addmods.add(arg);
 309             }
 310         },
 311         new Option(true, CommandOption.GENERATE_MODULE_INFO) {
 312             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 313                 if (task.command != null) {
 314                     throw new BadArgs("err.command.set", task.command, opt);
 315                 }
 316                 task.command = task.genModuleInfo(Paths.get(arg), false);
 317             }
 318         },
 319         new Option(true, CommandOption.GENERATE_OPEN_MODULE) {
 320             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 321                 if (task.command != null) {
 322                     throw new BadArgs("err.command.set", task.command, opt);
 323                 }
 324                 task.command = task.genModuleInfo(Paths.get(arg), true);
 325             }
 326         },
 327         new Option(true, CommandOption.CHECK_MODULES) {
 328             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 329                 if (task.command != null) {
 330                     throw new BadArgs("err.command.set", task.command, opt);
 331                 }
 332                 Set<String> mods =  Set.of(arg.split(","));
 333                 task.options.addmods.addAll(mods);
 334                 task.command = task.checkModuleDeps(mods);
 335             }
 336         },
 337         new Option(false, CommandOption.LIST_DEPS) {
 338             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 339                 if (task.command != null) {
 340                     throw new BadArgs("err.command.set", task.command, opt);
 341                 }
 342                 task.command = task.listModuleDeps(false);
 343             }
 344         },
 345         new Option(false, CommandOption.LIST_REDUCED_DEPS) {
 346             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 347                 if (task.command != null) {
 348                     throw new BadArgs("err.command.set", task.command, opt);
 349                 }
 350                 task.command = task.listModuleDeps(true);
 351             }
 352         },
 353 
 354         // ---- Target filtering options ----
 355         new Option(true, "-p", "-package", "--package") {
 356             void process(JdepsTask task, String opt, String arg) {
 357                 task.options.packageNames.add(arg);
 358             }
 359         },
 360         new Option(true, "-e", "-regex", "--regex") {
 361             void process(JdepsTask task, String opt, String arg) {
 362                 task.options.regex = Pattern.compile(arg);
 363             }
 364         },
 365         new Option(true, "--require") {
 366             void process(JdepsTask task, String opt, String arg) {
 367                 task.options.requires.add(arg);
 368                 task.options.addmods.add(arg);
 369             }
 370         },
 371         new Option(true, "-f", "-filter") {
 372             void process(JdepsTask task, String opt, String arg) {


 419 
 420         new Option(false, "-I", "--inverse") {
 421             void process(JdepsTask task, String opt, String arg) {
 422                 task.options.inverse = true;
 423                 // equivalent to the inverse of compile-time view analysis
 424                 task.options.compileTimeView = true;
 425                 task.options.filterSamePackage = true;
 426                 task.options.filterSameArchive = true;
 427             }
 428         },
 429 
 430         new Option(false, "--compile-time") {
 431             void process(JdepsTask task, String opt, String arg) {
 432                 task.options.compileTimeView = true;
 433                 task.options.filterSamePackage = true;
 434                 task.options.filterSameArchive = true;
 435                 task.options.depth = 0;
 436             }
 437         },
 438 











 439         new HiddenOption(false, "-fullversion") {
 440             void process(JdepsTask task, String opt, String arg) {
 441                 task.options.fullVersion = true;
 442             }
 443         },
 444         new HiddenOption(false, "-showlabel") {
 445             void process(JdepsTask task, String opt, String arg) {
 446                 task.options.showLabel = true;
 447             }
 448         },
 449         new HiddenOption(false, "--hide-show-module") {
 450             void process(JdepsTask task, String opt, String arg) {
 451                 task.options.showModule = false;
 452             }
 453         },
 454         new HiddenOption(true, "-depth") {
 455             void process(JdepsTask task, String opt, String arg) throws BadArgs {
 456                 try {
 457                     task.options.depth = Integer.parseInt(arg);
 458                 } catch (NumberFormatException e) {


< prev index next >