rgoussu@goussu: ~/library/java/jdk-and-tools
~/library/java/jdk-and-tools cat jdeps.md

jdeps — dependency analysis

# The jdeps analyser — class, package and module-level dependencies, JDK-internal usage, and feeding jlink.

Conceptsaved 2026-08-09 #java#jdk#tooling#modules

Overview

jdeps statically analyses class files and reports what they depend on — at class, package or module granularity. It exists chiefly as the migration companion to the module system: it tells you which platform modules an application really needs, whether it leans on JDK-internal APIs, and can draft a module-info.java for a plain jar.

Key points

  • Granularity: default is package-level per jar; -verbose:class drills to classes, -summary (-s) rolls up to module/jar level.
  • -jdkinternals: flags uses of sun.*/jdk.internal.* APIs and suggests the supported replacement — the first thing to run when a JDK upgrade breaks a legacy app.
  • --generate-module-info dir: emits a draft module-info.java per jar from observed dependencies — a starting point for modularising, not a finished descriptor (it cannot see reflection).
  • --print-module-deps: prints the comma-separated platform module list, exactly the format jlink --add-modules expects — the standard step when cutting minimal runtime images for containers.
  • Scope control: --multi-release 21 for MR-jars; -R (recursive over transitive deps), --ignore-missing-deps when the full classpath isn't available (common with Spring Boot fat jars — analyse the exploded BOOT-INF instead).
  • Blind spots: purely static — reflection, ServiceLoader providers and Class.forName usage are invisible, so treat its output as a lower bound.

Examples

jdeps -jdkinternals legacy-app.jar
jdeps --print-module-deps --ignore-missing-deps app.jar   # → java.base,java.sql,...
jdeps --generate-module-info out lib/plain-lib.jar

Related

  • The JDK, the JRE & their tools — parent catalog of the toolchain.
  • jlink — consumes --print-module-deps output to build minimal runtimes.
  • javap — the per-class view when jdeps' aggregate view isn't enough.
  • Build ecosystem — build plugins wrap jdeps for image-building pipelines.