首頁 > Java > java教程 > 主體

Java 9中Jdeps和Jdeprscan工具的差異是什麼?

WBOY
發布: 2023-09-16 15:21:03
轉載
1079 人瀏覽過

Java 9中Jdeps和Jdeprscan工具之间的区别是什么?

Jdeps工具可用來分析我們的類別的依賴關係。執行「jdeps -jdkinternals jararchive.jar」命令會列印使用 Java 內部 API 的所有類別的清單。 Jdeps 工具傳回依賴項的詳細描述,而 Jdeprscan 是另一個有用的工具,特別與「-for-removal」標誌結合使用。此工具向我們顯示給定jar 存檔對已棄用的API的所有使用,並且只能顯示jdk 方法的已棄用的使用,並且無法使用此工具檢查第三方jar中的棄用情況.

Jdeps工具:

  • jdeps」是一個類別依賴分析工具,可用於套件級別和類別級別依賴關係。
  • jdeps class_file」指令列印給定類別檔案的套件層級依賴關係。
  • “jdeps” -verbose”命令列印類別級依賴關係。
  • jdeps jar_file”命令列印給定jar 檔案的包級依賴關係。
  • jdeps --inverse --require module_name”命令列印給定java 模組的包級反向依賴關係。
##在下面,我們可以使用「

jdeps --help」指令查看完整的選項清單。

<strong>C:\Users\user>jdeps --help
Usage: jdeps <options> <path ...>]
<path> can be a pathname to a .class file, a directory, a JAR file.

Possible options include:
  -dotoutput <dir>
  --dot-output <dir>      Destination directory for DOT file output
  -s        -summary      Print dependency summary only.
  -v        -verbose      Print all class level dependences
                          Equivalent to -verbose:class -filter:none.
  -verbose:package        Print package-level dependences excluding
                          dependences within the same package by default
  -verbose:class          Print class-level dependences excluding
                          dependences within the same package by default
  -apionly
  --api-only              Restrict analysis to APIs i.e. dependences
                          from the signature of public and protected
                          members of public classes including field
                          type, method parameter types, returned type,
                          checked exception types etc.
  -jdkinternals
  --jdk-internals         Finds class-level dependences on JDK internal
                          APIs. By default, it analyzes all classes
                          on --class-path and input files unless -include
                          option is specified. This option cannot be
                          used with -p, -e and -s options.
                          WARNING: JDK internal APIs are inaccessible.
--check <module-name>[,<module-name>...
                          Analyze the dependence of the specified modules
                          It prints the module descriptor, the resulting
                          module dependences after analysis and the
                          graph after transition reduction. It also
                          identifies any unused qualified exports.
  --generate-module-info <dir>
                          Generate module-info.java under the specified
                          directory. The specified JAR files will be
                          analyzed. This option cannot be used with
                          --dot-output or --class-path. Use
                          --generate-open-module option for open modules.
  --generate-open-module <dir>
                          Generate module-info.java for the specified
                          JAR files under the specified directory as
                          open modules. This option cannot be used with
                          --dot-output or --class-path.
  --list-deps             Lists the dependences and use of JDK internal APIs.
  --list-reduced-deps     Same as --list-deps with not listing
                          the implied reads edges from the module graph
                          If module M1 depends on M2 and M3,
                          M2 requires public on M3, then M1 reading M3 is
                          implied and removed from the module graph.
  -cp <path>
  -classpath <path>
  --class-path <path>     Specify where to find class files
  --module-path <module path>
                          Specify module path
  --upgrade-module-path <module path>
                          Specify upgrade module path
  --system <java-home>    Specify an alternate system module path
  --add-modules <module-name>[,<module-name>...]
                          Adds modules to the root set for analysis
  -m <module-name>
  --module <module-name>  Specify the root module for analysis
  --multi-release <version>
                          Specifies the version when processing
                          multi-release jar files. should
                          be integer >= 9 or base.

Options to filter dependences:
  -p <pkg>
  -package <pkg>
  --package <pkg>           Finds dependences matching the given package
                            name (may be given multiple times).
  -e <regex>
  -regex <regex>
  --regex <regex>           Finds dependences matching the given pattern.
  --require <module-name>   Finds dependences matching the given module
                            name (may be given multiple times). --package,
                            --regex, --require are mutual exclusive.
  -f <regex> -filter <regex> Filter dependences matching the given
                             pattern. If given multiple times, the last
                             one will be used.
  -filter:package            Filter dependences within the same package.
                             This is the default.
  -filter:archive            Filter dependences within the same archive.
  -filter:module             Filter dependences within the same module.
  -filter:none               No -filter:package and -filter:archive
                             filtering. Filtering specified via the
                             -filter option still applies.

Options to filter classes to be analyzed:
  -include <regex>           Restrict analysis to classes matching pattern
                             This option filters the list of classes to
                             be analyzed. It can be used together with
                             -p and -e which apply pattern to the dependences

  -P         -profile        Show profile containing a package
  -R         -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.
  -I          --inverse      Analyzes the dependences per other given options

                             and then find all artifacts that directly
                             and indirectly depend on the matching nodes.
                             This is equivalent to the inverse of
                             compile-time view analysis and print
                             dependency summary. This option must use
                             with --require, --package or --regex option.
  --compile-time             Compile-time view of transitive dependences
                             i.e. compile-time view of -R option.
                             Analyzes the dependences per other given options
 
                             If a dependence is found from a directory,
                             a JAR file or a module, all c*lasses in that
                             containing archive are analyzed.
  -q           - quiet       Do not show missing dependences from
                             --generate-module-info output.
  -version     --version     Version information</strong>
登入後複製

jdeprscan 工具:

  • jdeprscan# 」是一個Java 棄用API 掃描器工具,可用來掃描棄用的API 元素。
  • jdeprscan class_file」指令掃描給定jJava 類別檔案中已棄用的API 。
  • jdeprscan jar_file」指令掃描給定jar 檔案的已棄用API。
  • jdeprscan --release X」指令掃描特定JDK 版本的已棄用API。
  • jdeprscan --list --release X」指令列出了特定JDK 版本的所有已棄用的API。
#在下面,我們可以使用「

jdeprscan --hel< strong>p」指令來查看完整的選項清單。

<strong>C:\Users\User>jdeprscan --help
Usage: jdeprscan [options] {dir|jar|class} ...

options:
 --class-path PATH
 --for-removal
 --full-version
 -h --help
 -l --list
 --release 6|7|8|9
 -v --verbose
 --version

Scans each argument for usages of deprecated APIs. An argument may be a directory specifying the root of a package hierarchy,
a JAR file, a class file, or a class name. The class name must be specified using a fully qualified class name using the $ separator
character for nested classes, for example,
java.lang.Thread$State
The --class-path option provides a search path for resolution of dependent classes.
The --for-removal option limits scanning or listing to APIs that are
deprecated for removal. Cannot be used with a release value of 6, 7, or 8.
The --full-version option prints out the full version string of the tool.
The --help option prints out a full help message.
The --list (-l) option prints out the set of deprecated APIs. No scanning is done,
so no directory, jar, or class arguments should be provided.
The --release option specifies the Java SE release that provides the set of deprecated APIs for scanning.
The --verbose (-v) option enables additional message output during processing.
The --version option prints out the abbreviated version string of the tool.</strong>
登入後複製

以上是Java 9中Jdeps和Jdeprscan工具的差異是什麼?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:tutorialspoint.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板