Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Java

Khác biệt giữa công cụ Jdeps và Jdeprscan trong Java 9?

Công cụ Jdeps dùng để phân tích phụ thuộc của các class. Chạy lệnh jdeps -jdkinternals jararchive.jar in danh sách tất cả class dùng Java internal API. Jdeps trả về mô tả chi tiết phụ thuộc, trong khi Jdeprscan là công cụ khác đặc biệt dùng kết hợp với cờ --for-removal. Công cụ này hiển thị tất cả việc sử dụng API deprecated bởi một jar archive cho trước, chỉ hiện các dùng deprecated của JDK methods, không dùng để kiểm tra deprecation trong third party jar.

Công cụ Jdeps:

  • jdeps – trình phân tích phụ thuộc class dùng cho package-level và class-level dependencies.
  • jdeps class_file – in package-level dependencies của class file cho trước.
  • jdeps -verbose – in class-level dependencies.
  • jdeps jar_file – in package-level dependencies của jar file cho trước.
  • jdeps --inverse --require module_name – in package level reverse dependencies của java module cho trước.

Dưới đây dùng jdeps --help để xem danh sách tùy chọn đầy đủ.

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
  -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...
  -jdkinternals        --jdk-internals     Finds class-level dependences on JDK internal APIs...
  --check <module-name>[,<module-name>...]  Analyze the dependence of the specified modules...
  --generate-module-info <dir>              Generate module-info.java under the specified directory...
  --generate-open-module <dir>              Generate module-info.java for the specified JAR files as open modules...
  --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...
  -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...
  Options to filter dependences:
  -p <pkg>      -package <pkg>   --package <pkg>     Finds dependences matching the given package name...
  -e <regex>    -regex <regex>   --regex <regex>     Finds dependences matching the given pattern...
  --require <module-name>                  Finds dependences matching the given module name...
  -f <regex>   -filter <regex>              Filter dependences matching the given pattern...
  -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...
  Options to filter classes to be analyzed:
  -include <regex>                         Restrict analysis to classes matching pattern...
  -P              -profile                 Show profile containing a package
  -R              -recursive               Recursively traverse all run-time dependences...
  -I              --inverse                Analyzes the dependences per other given options...
  --compile-time                           Compile-time view of transitive dependences...
  -q              - quiet                  Do not show missing dependences from --generate-module-info output.
  -version        --version                Version information

Công cụ jdeprscan:

  • jdeprscan – Java Deprecated API Scanner tool quét các API element deprecated.
  • jdeprscan class_file – quét deprecated APIs của Java class file cho trước.
  • jdeprscan jar_file – quét deprecated APIs của jar file cho trước.
  • jdeprscan --release X – quét deprecated APIs của JDK release cụ thể.
  • jdeprscan --list --release X – liệt kê tất cả deprecated APIs của JDK release cụ thể.

Dùng jdeprscan --help để xem tùy chọn đầy đủ.

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...
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...
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...
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.