Course contentsShow
← Java
Lesson 2543 of 2,87047. Java Platform Module System (JPMS)Free lesson

Migration Strategy: From Automatic to Explicit Modules

Best practices for treating automatic modules as a temporary migration step toward full modularization.

Migration Strategy: From Automatic to Explicit Modules

You'll learn why automatic modules should be temporary stepping stones, not permanent solutions.

Automatic modules are incredibly useful during migration—they let you put legacy JARs on the module path without modifying them. However, treating them as a long-term solution is like putting a band-aid on structural damage. They lack the precision and safety guarantees that explicit modules provide.

Why Automatic Modules Are Temporary

Automatic modules have three significant weaknesses:

  1. They export everything — All packages become public API, even internal implementation details
  2. They require everything — They implicitly depend on all other modules, creating overly broad dependency graphs
  3. Unstable naming — Without an Automatic-Module-Name manifest entry, module names derive from filenames, which can change

These characteristics make automatic modules fragile foundations for production systems.

The Migration Path

Phase 1: Convert third-party JARs to automatic modules (place on module path, add Automatic-Module-Name if you control the JAR)

Phase 2: Write explicit module-info.java for your own code, using requires to reference automatic modules

Phase 3: Replace automatic modules with explicit versions:

  • Contact library maintainers for modular releases
  • Fork and modularize critical dependencies yourself
  • Use jdeps to understand exact package dependencies before converting

Phase 4: Validate with jdeps that all automatic modules are eliminated

Best Practices

  • Document temporary workarounds — Track which dependencies remain automatic
  • Monitor upstream projects — Many libraries are actively adding module support
  • Prioritize by risk — Convert high-churn or security-critical dependencies first
  • Test incrementally — Each automatic→explicit conversion should be validated independently

Key Takeaway: Automatic modules are bridges, not destinations—plan actively to replace them with explicit modules to achieve JPMS's full encapsulation and maintainability benefits.