Summary
Change jdeps --print-module-deps
, --list-deps
, and --list-reduce-deps
options to do transitive dependence analysis by default. In addition,
if any dependences are not found, these options will report as an error.
Three new options are added:
--ignore-missing-deps
option to suppress missing dependence error.--missing-deps
option is a convenient filtering option that finds the missing dependences--no-recursive
option to restore the non-transitive behavior.-R
and-recursive
are the existing options to request transitive behavor. This CSR also adds a corresponding GNU-style long term--recursive
to make this list of options consistent.
Problem
jdeps --print-module-deps
finds the modules required by the specified
application. Its result can be used to create a runtime image for such
application to run.
The current behavior does not report missing dependences. In addition,
--print-module-deps
only reports module dependences required by app.jar.
To include the transitive module dependences required by libs, if referenced,
-R option can be used.
The application may fail to run on the runtime image created by the
output from jdeps --print-module-deps
since missing dependences
or the libraries on class path are not analyzed. The user won't find
out until it creates the image and run the tests to verify.
Solution
Improve the default behavior of jdeps --print-module-deps
,
--list-deps
, and --list-reduce-deps
options:
- report missing dependences as an error so that users can ensure all dependences are found. The --ignore-missing-deps option can be used to ignore missing deps.
- do transitive dependence analysis
Specification
Module dependence analysis options:
:
--list-deps Lists the module dependences. It also prints
any internal API packages if referenced.
This option transitively analyzes libraries on
class path and module path if referenced.
Use --no-recursive option for non-transitive
dependency analysis.
--list-reduced-deps Same as --list-deps with not listing
the implied reads edges from the module graph.
If module M1 reads M2, and M2 requires
transitive on M3, then M1 reading M3 is implied
and is not shown in the graph.
--print-module-deps Same as --list-reduced-deps with printing
a comma-separated list of module dependences.
This output can be used by jlink --add-modules
in order to create a custom image containing
those modules and their transitive dependences.
--ignore-missing-deps Ignore missing dependences.
Options to filter dependences:
:
--missing-deps Finds missing dependences. This option
cannot be used with -p, -e and -s options.
:
--recursive Recursively traverse all run-time dependences.
The -R option implies -filter:none. If -p,
-e, -f option is specified, only the matching
dependences are analyzed.
--no-recursive Do not recursively traverse dependences.
Diff on the help message:
diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
@@ -57,6 +57,13 @@
\ name (may be given multiple times). --package,\n\
\ --regex, --require are mutual exclusive.
+main.opt.missing-deps=\
+\ --missing-deps Finds missing dependences. This option\n\
+\ cannot be used with -p, -e and -s options.
+
+main.opt.ignore-missing-deps=\
+\ --ignore-missing-deps Ignore missing dependences.
+
main.opt.include=\n\
\Options to filter classes to be analyzed:\n\
\ -include <regex> Restrict analysis to classes matching pattern\n\
@@ -86,13 +93,18 @@
\ Adds modules to the root set for analysis
main.opt.R=\
-\ -R -recursive Recursively traverse all run-time dependences.\n\
+\ -R\n\
+\ --recursive Recursively traverse all run-time dependences.\n\
\ The -R option implies -filter:none. If -p,\n\
\ -e, -f option is specified, only the matching\n\
\ dependences are analyzed.
+main.opt.no-recursive=\
+\ --no-recursive Do not recursively traverse dependences.
+
@@ -157,9 +169,11 @@
main.opt.list-deps=\
\ --list-deps Lists the module dependences. It also prints\n\
-\ any JDK internal API packages if referenced.\n\
-\ This option does not show dependences on the\n\
-\ class path or not found.
+\ any internal API packages if referenced.\n\
+\ This option transitively analyzes libraries on\n\
+\ class path and module path if referenced.\n\
+\ Use --no-recursive option for non-transitive\n\
+\ dependency analysis.
- csr of
-
JDK-8213909 jdeps --print-module-deps should report missing dependences
- Resolved