# HG changeset patch # User mchung # Date 1475209869 25200 # Node ID 6112540cd0c1ae54fd90f30501c7016ada8e6dda # Parent 0dea223af562653f8de28544bc18fba0bf4b29bd 8166238: Update jdeps for GNU-style long form options Reviewed-by: alanb diff -r 0dea223af562 -r 6112540cd0c1 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Thu Sep 29 17:24:10 2016 +0000 +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Thu Sep 29 21:31:09 2016 -0700 @@ -150,7 +150,7 @@ task.options.help = true; } }, - new Option(true, "-dotoutput") { + new Option(true, "-dotoutput", "--dot-output") { void process(JdepsTask task, String opt, String arg) throws BadArgs { Path p = Paths.get(arg); if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) { @@ -191,7 +191,7 @@ } } }, - new Option(false, "-apionly") { + new Option(false, "-apionly", "--api-only") { void process(JdepsTask task, String opt, String arg) { task.options.apiOnly = true; } @@ -203,7 +203,7 @@ task.options.addmods.addAll(mods); } }, - new Option(true, "--gen-module-info") { + new Option(true, "--generate-module-info") { void process(JdepsTask task, String opt, String arg) throws BadArgs { Path p = Paths.get(arg); if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) { @@ -212,7 +212,7 @@ task.options.genModuleInfo = Paths.get(arg); } }, - new Option(false, "-jdkinternals") { + new Option(false, "-jdkinternals", "--jdk-internals") { void process(JdepsTask task, String opt, String arg) { task.options.findJDKInternals = true; task.options.verbose = CLASS; @@ -263,19 +263,36 @@ task.options.addmods.add(arg); } }, + new Option(true, "--multi-release") { + void process(JdepsTask task, String opt, String arg) throws BadArgs { + if (arg.equalsIgnoreCase("base")) { + task.options.multiRelease = JarFile.baseVersion(); + } else { + try { + int v = Integer.parseInt(arg); + if (v < 9) { + throw new BadArgs("err.invalid.arg.for.option", arg); + } + } catch (NumberFormatException x) { + throw new BadArgs("err.invalid.arg.for.option", arg); + } + task.options.multiRelease = Runtime.Version.parse(arg); + } + } + }, // ---- Target filtering options ---- - new Option(true, "-p", "-package") { + new Option(true, "-p", "-package", "--package") { void process(JdepsTask task, String opt, String arg) { task.options.packageNames.add(arg); } }, - new Option(true, "-e", "-regex") { + new Option(true, "-e", "-regex", "--regex") { void process(JdepsTask task, String opt, String arg) { task.options.regex = Pattern.compile(arg); } }, - new Option(true, "-requires") { + new Option(true, "--require") { void process(JdepsTask task, String opt, String arg) { task.options.requires.add(arg); } @@ -336,7 +353,7 @@ } }, - new Option(false, "-I", "-inverse") { + new Option(false, "-I", "--inverse") { void process(JdepsTask task, String opt, String arg) { task.options.inverse = true; // equivalent to the inverse of compile-time view analysis @@ -361,7 +378,7 @@ } }, - new Option(false, "-version") { + new Option(false, "-version", "--version") { void process(JdepsTask task, String opt, String arg) { task.options.version = true; } @@ -390,23 +407,6 @@ } } }, - new Option(true, "--multi-release") { - void process(JdepsTask task, String opt, String arg) throws BadArgs { - if (arg.equalsIgnoreCase("base")) { - task.options.multiRelease = JarFile.baseVersion(); - } else { - try { - int v = Integer.parseInt(arg); - if (v < 9) { - throw new BadArgs("err.invalid.arg.for.option", arg); - } - } catch (NumberFormatException x) { - throw new BadArgs("err.invalid.arg.for.option", arg); - } - task.options.multiRelease = Runtime.Version.parse(arg); - } - } - }, }; private static final String PROGNAME = "jdeps"; diff -r 0dea223af562 -r 6112540cd0c1 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties Thu Sep 29 17:24:10 2016 +0000 +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties Thu Sep 29 21:31:09 2016 -0700 @@ -13,162 +13,168 @@ main.opt.h=\ \ -h -? -help\n\ -\ --help Print this usage message +\ --help Print this usage message main.opt.version=\ -\ -version Version information +\ -version --version Version information main.opt.v=\ -\ -v -verbose Print all class level dependencies\n\ -\ Equivalent to -verbose:class -filter:none.\n\ -\ -verbose:package Print package-level dependencies excluding\n\ -\ dependencies within the same package by default\n\ -\ -verbose:class Print class-level dependencies excluding\n\ -\ dependencies within the same package by default +\ -v -verbose Print all class level dependences\n\ +\ Equivalent to -verbose:class -filter:none.\n\ +\ -verbose:package Print package-level dependences excluding\n\ +\ dependences within the same package by default\n\ +\ -verbose:class Print class-level dependences excluding\n\ +\ dependences within the same package by default main.opt.s=\ -\ -s -summary Print dependency summary only. +\ -s -summary Print dependency summary only. main.opt.f=\ -\ -f -filter Filter dependences matching the given\n\ -\ pattern. If given multiple times, the last\n\ -\ one will be used.\n\ -\ -filter:package Filter dependences within the same package.\n\ -\ This is the default.\n\ -\ -filter:archive Filter dependences within the same archive.\n\ -\ -filter:module Filter dependences within the same module.\n\ -\ -filter:none No -filter:package and -filter:archive\n\ -\ filtering. Filtering specified via the\n\ -\ -filter option still applies.\n\ +\ -f -filter Filter dependences matching the given\n\ +\ pattern. If given multiple times, the last\n\ +\ one will be used.\n\ +\ -filter:package Filter dependences within the same package.\n\ +\ This is the default.\n\ +\ -filter:archive Filter dependences within the same archive.\n\ +\ -filter:module Filter dependences within the same module.\n\ +\ -filter:none No -filter:package and -filter:archive\n\ +\ filtering. Filtering specified via the\n\ +\ -filter option still applies.\n\ main.opt.p=\n\ -\Options to filter dependencies:\n\ -\ -p -package Finds dependences matching the given package\n\ -\ name (may be given multiple times). +\Options to filter dependences:\n\ +\ -p \n\ +\ -package \n\ +\ --package Finds dependences matching the given package\n\ +\ name (may be given multiple times). main.opt.e=\ -\ -e -regex Finds dependences matching the given pattern. +\ -e \n\ +\ -regex \n\ +\ --regex Finds dependences matching the given pattern. -main.opt.requires=\ -\ -requires Finds dependences matching the given module\n\ -\ name (may be given multiple times).\n\ -\ -package, -regex, -requires are mutual exclusive. +main.opt.require=\ +\ --require Finds dependences matching the given module\n\ +\ name (may be given multiple times). --package,\n\ +\ --regex, --require are mutual exclusive. main.opt.include=\n\ \Options to filter classes to be analyzed:\n\ -\ -include Restrict analysis to classes matching pattern\n\ -\ This option filters the list of classes to\n\ -\ be analyzed. It can be used together with\n\ -\ -p and -e which apply pattern to the dependences +\ -include Restrict analysis to classes matching pattern\n\ +\ This option filters the list of classes to\n\ +\ be analyzed. It can be used together with\n\ +\ -p and -e which apply pattern to the dependences main.opt.P=\ -\ -P -profile Show profile containing a package +\ -P -profile Show profile containing a package main.opt.cp=\ \ -cp \n\ \ -classpath \n\ -\ --class-path Specify where to find class files +\ --class-path Specify where to find class files main.opt.module-path=\ -\ --module-path ... Specify module path +\ --module-path Specify module path main.opt.upgrade-module-path=\ -\ --upgrade-module-path ... Specify upgrade module path +\ --upgrade-module-path Specify upgrade module path main.opt.system=\ -\ --system Specify an alternate system module path +\ --system Specify an alternate system module path main.opt.add-modules=\ \ --add-modules [,...]\n\ -\ Adds modules to the root set for analysis +\ Adds modules to the root set for analysis main.opt.m=\ \ -m \n\ -\ --module Specify the root module for analysis +\ --module Specify the root module for analysis main.opt.R=\ -\ -R -recursive Recursively traverse all run-time dependencies.\n\ -\ The -R option implies -filter:none. If -p,\n\ -\ -e, -foption is specified, only the matching\n\ -\ dependences are analyzed. +\ -R -recursive Recursively traverse all run-time dependences.\n\ +\ The -R option implies -filter:none. If -p,\n\ +\ -e, -foption is specified, only the matching\n\ +\ dependences are analyzed. main.opt.I=\ -\ -I -inverse Analyzes the dependences per other given options\n\ -\ and then find all artifacts that directly\n\ -\ and indirectly depend on the matching nodes.\n\ -\ This is equivalent to the inverse of\n\ -\ compile-time view analysis and print\n\ -\ dependency summary. This option must use\n\ -\ with -requires, -package or -regex option. +\ -I --inverse Analyzes the dependences per other given options\n\ +\ and then find all artifacts that directly\n\ +\ and indirectly depend on the matching nodes.\n\ +\ This is equivalent to the inverse of\n\ +\ compile-time view analysis and print\n\ +\ dependency summary. This option must use\n\ +\ with --require, --package or --regex option. main.opt.compile-time=\ -\ --compile-time Compile-time view of transitive dependencies\n\ -\ i.e. compile-time view of -R option.\n\ -\ Analyzes the dependences per other given options\n\ -\ If a dependence is found from a directory,\n\ -\ a JAR file or a module, all classes in that \n\ -\ containing archive are analyzed. +\ --compile-time Compile-time view of transitive dependences\n\ +\ i.e. compile-time view of -R option.\n\ +\ Analyzes the dependences per other given options\n\ +\ If a dependence is found from a directory,\n\ +\ a JAR file or a module, all classes in that \n\ +\ containing archive are analyzed. main.opt.apionly=\ -\ -apionly Restrict analysis to APIs i.e. dependences\n\ -\ from the signature of public and protected\n\ -\ members of public classes including field\n\ -\ type, method parameter types, returned type,\n\ -\ checked exception types etc. +\ -apionly\n\ +\ --api-only Restrict analysis to APIs i.e. dependences\n\ +\ from the signature of public and protected\n\ +\ members of public classes including field\n\ +\ type, method parameter types, returned type,\n\ +\ checked exception types etc. -main.opt.gen-module-info=\ -\ --gen-module-info Generate module-info.java under the specified\n\ -\ directory. The specified JAR files will be\n\ -\ analyzed. This option cannot be used with\n\ -\ -dotoutput or -cp. +main.opt.generate-module-info=\ +\ --generate-module-info Generate module-info.java under the specified\n\ +\ directory. The specified JAR files will be\n\ +\ analyzed. This option cannot be used with\n\ +\ --dot-output or --class-path. main.opt.check=\ \ --check [,...\n\ -\ Analyze the dependence of the specified modules\n\ -\ It prints the module descriptor, the resulting\n\ -\ module dependences after analysis and the\n\ -\ graph after transition reduction. It also\n\ -\ identifies any unused qualified exports. +\ Analyze the dependence of the specified modules\n\ +\ It prints the module descriptor, the resulting\n\ +\ module dependences after analysis and the\n\ +\ graph after transition reduction. It also\n\ +\ identifies any unused qualified exports. main.opt.dotoutput=\ -\ -dotoutput Destination directory for DOT file output +\ -dotoutput \n\ +\ --dot-output Destination directory for DOT file output main.opt.jdkinternals=\ -\ -jdkinternals Finds class-level dependences on JDK internal\n\ -\ APIs. By default, it analyzes all classes\n\ -\ on -classpath and input files unless -include\n\ -\ option is specified. This option cannot be\n\ -\ used with -p, -e and -s options.\n\ -\ WARNING: JDK internal APIs are inaccessible. +\ -jdkinternals\n\ +\ --jdk-internals Finds class-level dependences on JDK internal\n\ +\ APIs. By default, it analyzes all classes\n\ +\ on --class-path and input files unless -include\n\ +\ option is specified. This option cannot be\n\ +\ used with -p, -e and -s options.\n\ +\ WARNING: JDK internal APIs are inaccessible. main.opt.depth=\ -\ -depth= Specify the depth of the transitive\n\ -\ dependency analysis +\ -depth= Specify the depth of the transitive\n\ +\ dependency analysis main.opt.q=\ -\ -q -quiet Do not show missing dependencies from \n\ -\ -genmoduleinfo output. +\ -q -quiet Do not show missing dependences from \n\ +\ --generate-module-info output. main.opt.multi-release=\ -\ --multi-release Specifies the version when processing\n\ -\ multi-release jar files. should\n\ -\ be integer >= 9 or base. +\ --multi-release Specifies the version when processing\n\ +\ multi-release jar files. should\n\ +\ be integer >= 9 or base. err.unknown.option=unknown option: {0} err.missing.arg=no value given for {0} err.invalid.arg.for.option=invalid argument for option: {0} err.option.after.class=option must be specified before classes: {0} -err.genmoduleinfo.not.jarfile={0} not valid for --gen-module-info option (must be non-modular JAR file) +err.genmoduleinfo.not.jarfile={0} not valid for --generate-module-info option (must be non-modular JAR file) err.profiles.msg=No profile information err.exception.message={0} err.invalid.path=invalid path: {0} err.invalid.module.option=Cannot set {0} with {1} option. -err.invalid.filters=Only one of -package (-p), -regex (-e), -requires option can be set +err.invalid.filters=Only one of --package (-p), --regex (-e), --require option can be set err.module.not.found=module not found: {0} err.root.module.not.set=root module set empty -err.invalid.inverse.option={0} cannot be used with -inverse option -err.inverse.filter.not.set={0} cannot be used with -inverse option +err.invalid.inverse.option={0} cannot be used with --inverse option err.multirelease.option.exists={0} is not a multi-release jar file, but the --multi-release option is set err.multirelease.option.notfound={0} is a multi-release jar file, but the --multi-release option is not set err.multirelease.version.associated=class {0} already associated with version {1}, trying to add version {2} @@ -178,7 +184,7 @@ warn.replace.useJDKInternals=\ JDK internal APIs are unsupported and private to JDK implementation that are\n\ subject to be removed or changed incompatibly and could break your application.\n\ -Please modify your code to eliminate dependency on any JDK internal APIs.\n\ +Please modify your code to eliminate dependence on any JDK internal APIs.\n\ For the most recent update on JDK internal API replacements, please check:\n\ {0} diff -r 0dea223af562 -r 6112540cd0c1 langtools/test/tools/jdeps/APIDeps.java --- a/langtools/test/tools/jdeps/APIDeps.java Thu Sep 29 17:24:10 2016 +0000 +++ b/langtools/test/tools/jdeps/APIDeps.java Thu Sep 29 21:31:09 2016 -0700 @@ -135,7 +135,7 @@ "java.util.Set", "c.C", "d.D", "c.I", "e.E", "m.Bar"}, new String[] {"compact1", testDirBasename, mDir.getName()}, - new String[] {"-classpath", testDir.getPath(), "-verbose", "-P", "-apionly"}); + new String[] {"-classpath", testDir.getPath(), "-verbose", "-P", "--api-only"}); return errors; } diff -r 0dea223af562 -r 6112540cd0c1 langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java --- a/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java Thu Sep 29 17:24:10 2016 +0000 +++ b/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java Thu Sep 29 21:31:09 2016 -0700 @@ -116,7 +116,7 @@ @Test public void removedPackage() { Path file = Paths.get("q", "RemovedPackage.class"); - String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); + String[] output = JdepsUtil.jdeps("--jdk-internals", CLASSES_DIR.resolve(file).toString()); int i = 0; // expect no replacement while (i < output.length && !output[i].contains("Suggested Replacement")) { diff -r 0dea223af562 -r 6112540cd0c1 langtools/test/tools/jdeps/modules/GenModuleInfo.java --- a/langtools/test/tools/jdeps/modules/GenModuleInfo.java Thu Sep 29 17:24:10 2016 +0000 +++ b/langtools/test/tools/jdeps/modules/GenModuleInfo.java Thu Sep 29 21:31:09 2016 -0700 @@ -23,7 +23,7 @@ /* * @test - * @summary Tests jdeps --gen-module-info option + * @summary Tests jdeps --generate-module-info option * @library ../lib * @build CompilerUtils JdepsUtil * @modules jdk.jdeps/com.sun.tools.jdeps @@ -106,7 +106,7 @@ .map(mn -> LIBS_DIR.resolve(mn + ".jar")) .map(Path::toString); - JdepsUtil.jdeps(Stream.concat(Stream.of("--gen-module-info", DEST_DIR.toString()), + JdepsUtil.jdeps(Stream.concat(Stream.of("--generate-module-info", DEST_DIR.toString()), files).toArray(String[]::new)); // check file exists diff -r 0dea223af562 -r 6112540cd0c1 langtools/test/tools/jdeps/modules/InverseDeps.java --- a/langtools/test/tools/jdeps/modules/InverseDeps.java Thu Sep 29 17:24:10 2016 +0000 +++ b/langtools/test/tools/jdeps/modules/InverseDeps.java Thu Sep 29 21:31:09 2016 -0700 @@ -91,7 +91,7 @@ @DataProvider(name = "testrequires") public Object[][] expected1() { return new Object[][] { - // -requires and result + // --require and result { "java.sql", new String[][] { new String[] { "java.sql", "m5" }, } @@ -117,7 +117,7 @@ @Test(dataProvider = "testrequires") public void testrequires(String name, String[][] expected) throws Exception { - String cmd1 = String.format("jdeps -inverse --module-path %s -requires %s --add-modules %s%n", + String cmd1 = String.format("jdeps --inverse --module-path %s --require %s --add-modules %s%n", MODS_DIR, name, modules.stream().collect(Collectors.joining(","))); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) { @@ -128,7 +128,7 @@ runJdeps(jdeps, expected); } - String cmd2 = String.format("jdeps -inverse --module-path %s -requires %s" + + String cmd2 = String.format("jdeps --inverse --module-path %s --require %s" + " --add-modules ALL-MODULE-PATH%n", LIBS_DIR, name); // automatic module @@ -164,7 +164,7 @@ @Test(dataProvider = "testpackage") public void testpackage(String name, String[][] expected) throws Exception { - String cmd = String.format("jdeps -inverse --module-path %s -package %s --add-modules %s%n", + String cmd = String.format("jdeps --inverse --module-path %s -package %s --add-modules %s%n", MODS_DIR, name, modules.stream().collect(Collectors.joining(","))); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) { jdeps.appModulePath(MODS_DIR.toString()) @@ -195,7 +195,7 @@ @Test(dataProvider = "testregex") public void testregex(String name, String[][] expected) throws Exception { - String cmd = String.format("jdeps -inverse --module-path %s -regex %s --add-modules %s%n", + String cmd = String.format("jdeps --inverse --module-path %s -regex %s --add-modules %s%n", MODS_DIR, name, modules.stream().collect(Collectors.joining(","))); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) { @@ -240,7 +240,7 @@ Path jarfile = LIBS_DIR.resolve("m7.jar"); - String cmd1 = String.format("jdeps -inverse -classpath %s -regex %s %s%n", + String cmd1 = String.format("jdeps --inverse -classpath %s -regex %s %s%n", cpath, name, jarfile); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) { jdeps.verbose("-verbose:class") @@ -253,7 +253,7 @@ Set paths = modules.stream() .map(mn -> LIBS_DIR.resolve(mn + ".jar")) .collect(Collectors.toSet()); - String cmd2 = String.format("jdeps -inverse -regex %s %s%n", name, paths); + String cmd2 = String.format("jdeps --inverse -regex %s %s%n", name, paths); try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) { jdeps.verbose("-verbose:class").regex(name); paths.forEach(jdeps::addRoot); diff -r 0dea223af562 -r 6112540cd0c1 langtools/test/tools/jdeps/modules/src/m3/module-info.java --- a/langtools/test/tools/jdeps/modules/src/m3/module-info.java Thu Sep 29 17:24:10 2016 +0000 +++ b/langtools/test/tools/jdeps/modules/src/m3/module-info.java Thu Sep 29 21:31:09 2016 -0700 @@ -24,7 +24,7 @@ module m3 { requires public java.sql; requires public m2; - requires java.logging; // TODO: --gen-module-info to do transitive reduction + requires java.logging; // TODO: --generate-module-info to do transitive reduction requires public m1; exports p3; }